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

naive fitting. More...

#include <yat/regression/NaiveWeighted.h>

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

Public Member Functions

 NaiveWeighted (void)
 The default constructor.
 
virtual ~NaiveWeighted (void)
 The destructor.
 
void fit (const utility::VectorBase &x, const utility::VectorBase &y, const utility::VectorBase &w)
 
double predict (const double x) const
 
double s2 (const 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

naive fitting.

Member Function Documentation

void theplu::yat::regression::NaiveWeighted::fit ( const utility::VectorBase x,
const utility::VectorBase y,
const utility::VectorBase w 
)
virtual

This function computes the best-fit for the naive model $ y = m $ from vectors x and y, by minimizing $ \sum w_i(y_i-m)^2 $. The weight $ w_i $ is proportional to the inverse of the variance for $ y_i $

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

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

Function predicting value using the naive model, i.e. a weighted average.

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::NaiveWeighted::s2 ( const double  w = 1) const
virtual

$ \frac{\sum w_i\epsilon_i^2}{ w \left(\frac{\left(\sum w_i\right)^2}{\sum w_i^2}-1\right)} $

Rescaling all weights, both in fit and the passed w, results in the same returned value.

Returns
Conditional variance of Y with weight w.

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

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

$ \frac{\sum w_i\epsilon_i^2}{ \left(\frac{\left(\sum w_i\right)^2}{\sum w_i^2}-1\right)\sum w_i} $

Returns
estimated squared error of model value in x

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 Tue Sep 26 2017 02:33:30 for yat by  doxygen 1.8.5