julian::SimpleLinearRegression Class Reference

Class implements simple linear regression. More...

#include <simpleLinearRegression.hpp>

Inheritance diagram for julian::SimpleLinearRegression:
julian::DeeplyCopyableRegression< SimpleLinearRegression > julian::Regression

Public Member Functions

void estimate (const std::vector< double > &x, const std::vector< double > &y)
 estimates the parameters basing on provided data More...
 
void estimate (const std::vector< double > &x, const std::vector< double > &y, const std::vector< double > &w)
 estimates the parameters basing on provided data and weights More...
 
double getSlope ()
 returns slope More...
 
double getIntercept ()
 returns intercept More...
 
std::vector< double > getCoefficient () const
 return coefficients of the regression More...
 
double operator() (double) const
 evaluates the linear regression model for x More...
 
- Public Member Functions inherited from julian::DeeplyCopyableRegression< SimpleLinearRegression >
virtual Regressionclone () const
 virtual copy constructor More...
 
- Public Member Functions inherited from julian::Regression
 Regression ()
 Constructor. More...
 
virtual ~Regression ()
 Destructor. More...
 

Private Attributes

double chi_sq_
 The sum of squares of the residuals from the best-fit line. More...
 
double cov00_
 Variance of the slope estimate. More...
 
double cov01_
 Covariance of the slope/intercept estimates. More...
 
double cov11_
 Variance of the intercept estimate. More...
 
double c0_
 Intercept of linear regression. More...
 
double c1_
 Slope of linear regression. More...
 

Detailed Description

Class implements simple linear regression.

Simple linear regression is a linear regression model with a single explanatory variable. The parameters of the regression are calculated by minimizing the OLS. In other words class computes the best-fit linear regression coefficients $(c_0, c_1)$ of the model $Y = c_0 + c_1 X$ for the dataset (x, y) by minimizing the sum: $\sum^{n}_{i=1} (Y_i - (c_1 X + c_0))^2 $

For more information see Wikipedia

Remarks
Class uses algorithm implemented in GSL

Member Function Documentation

void julian::SimpleLinearRegression::estimate ( const std::vector< double > &  x,
const std::vector< double > &  y 
)
virtual

estimates the parameters basing on provided data

Implements julian::Regression.

void julian::SimpleLinearRegression::estimate ( const std::vector< double > &  x,
const std::vector< double > &  y,
const std::vector< double > &  w 
)

estimates the parameters basing on provided data and weights

std::vector< double > julian::SimpleLinearRegression::getCoefficient ( ) const
virtual

return coefficients of the regression

The i-th term of vector represents coefficient of $x^i$

Implements julian::Regression.

double julian::SimpleLinearRegression::getIntercept ( )

returns intercept

double julian::SimpleLinearRegression::getSlope ( )

returns slope

double julian::SimpleLinearRegression::operator() ( double  x) const
virtual

evaluates the linear regression model for x

Implements julian::Regression.

Member Data Documentation

double julian::SimpleLinearRegression::c0_
private

Intercept of linear regression.

double julian::SimpleLinearRegression::c1_
private

Slope of linear regression.

double julian::SimpleLinearRegression::chi_sq_
private

The sum of squares of the residuals from the best-fit line.

double julian::SimpleLinearRegression::cov00_
private

Variance of the slope estimate.

double julian::SimpleLinearRegression::cov01_
private

Covariance of the slope/intercept estimates.

double julian::SimpleLinearRegression::cov11_
private

Variance of the intercept estimate.


The documentation for this class was generated from the following files:
  • C:/Unix/home/OEM/jULIAN/src/mathematics/regressions/simpleLinearRegression.hpp
  • C:/Unix/home/OEM/jULIAN/src/mathematics/regressions/simpleLinearRegression.cpp