yat  0.13.2pre
Public Member Functions | Protected Attributes | List of all members
theplu::yat::regression::LinearWeighted Class Reference

linear regression. More...

#include <yat/regression/LinearWeighted.h>

Inheritance diagram for theplu::yat::regression::LinearWeighted:
theplu::yat::regression::OneDimensionalWeighted

Public Member Functions

 LinearWeighted (void)
 The default constructor.
 
virtual ~LinearWeighted (void)
 The destructor.
 
double alpha (void) const
 
double alpha_var (void) const
 
double beta (void) const
 
double beta_var (void) const
 
void fit (const utility::VectorBase &x, const utility::VectorBase &y, const utility::VectorBase &w)
 
double predict (const double x) const
 
double s2 (double w=1) const
 
double standard_error2 (const double x) const
 
double prediction_error2 (const double x, const double w=1.0) const
 
double r2 (void) const
 

Protected Attributes

statistics::AveragerPairWeighted ap_
 
double chisq_
 Chi-squared. More...
 

Detailed Description

linear regression.

Member Function Documentation

double theplu::yat::regression::LinearWeighted::alpha ( void  ) const

$ alpha $ is estimated as $ \frac{\sum w_iy_i}{\sum w_i} $

Returns
the parameter $ \alpha $
double theplu::yat::regression::LinearWeighted::alpha_var ( void  ) const

Variance is estimated as $ \frac{s^2}{\sum w_i} $

See Also
s2()
Returns
variance of parameter $ \alpha $
double theplu::yat::regression::LinearWeighted::beta ( void  ) const

$ beta $ is estimated as $ \frac{\sum w_i(y_i-m_y)(x_i-m_x)}{\sum w_i(x_i-m_x)^2} $

Returns
the parameter $ \beta $
double theplu::yat::regression::LinearWeighted::beta_var ( void  ) const

Variance is estimated as $ \frac{s^2}{\sum w_i(x_i-m_x)^2} $

See Also
s2()
Returns
variance of parameter $ \beta $
void theplu::yat::regression::LinearWeighted::fit ( const utility::VectorBase x,
const utility::VectorBase y,
const utility::VectorBase w 
)
virtual

This function computes the best-fit linear regression coefficients $ (\alpha, \beta)$ of the model $ y = \alpha + \beta (x-m_x) $ from vectors x and y, by minimizing $ \sum{w_i(y_i - \alpha - \beta (x-m_x))^2} $, where $ m_x $ is the weighted average. By construction $ \alpha $ and $ \beta $ are independent.

Implements theplu::yat::regression::OneDimensionalWeighted.

double theplu::yat::regression::LinearWeighted::predict ( const double  x) const
virtual

Function predicting value using the linear model: $ y =\alpha + \beta (x - m) $

Implements theplu::yat::regression::OneDimensionalWeighted.

double theplu::yat::regression::OneDimensionalWeighted::prediction_error2 ( const double  x,
const double  w = 1.0 
) const
inherited

The prediction error is defined as expected squared deviation a new data point (with weight w) will be from the model value $ E((Y|x - \hat{y}(x))^2|w) $ and is typically divided into the conditional variance ( see s2() ) given $ x $ and the squared standard error ( see standard_error2() ) of the model estimation in $ x $.

$ E((Y|x - E(Y|x))^2|w) + E((E(Y|x) - \hat{y}(x))^2) $

Returns
expected prediction error for a new data point in x with weight w.
double theplu::yat::regression::OneDimensionalWeighted::r2 ( void  ) const
inherited

r2 is defined as $ \frac{\sum w_i(y_i-\hat{y}_i)^2}{\sum w_i(y_i-m_y)^2} $ or the fraction of the variance explained by the regression model.

double theplu::yat::regression::LinearWeighted::s2 ( double  w = 1) const
virtual

Noise level for points with weight w.

Implements theplu::yat::regression::OneDimensionalWeighted.

double theplu::yat::regression::LinearWeighted::standard_error2 ( const double  x) const
virtual

estimated error $ y_{err} = \sqrt{ Var(\alpha) + Var(\beta)*(x-m)} $.

Implements theplu::yat::regression::OneDimensionalWeighted.

Member Data Documentation

statistics::AveragerPairWeighted theplu::yat::regression::OneDimensionalWeighted::ap_
protectedinherited

Averager for pair of x and y

double theplu::yat::regression::OneDimensionalWeighted::chisq_
protectedinherited

Chi-squared.

Chi-squared is defined as the $ \sum{w_i(\hat{y_i}-y_i)^2} $


The documentation for this class was generated from the following file:

Generated on Wed Jan 4 2017 02:23:08 for yat by  doxygen 1.8.5