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

Naive Regression. More...

#include <yat/regression/Naive.h>

Inheritance diagram for theplu::yat::regression::Naive:
theplu::yat::regression::OneDimensional

Public Member Functions

 Naive (void)
 The default constructor.
 
virtual ~Naive (void)
 The destructor.
 
void fit (const utility::VectorBase &x, const utility::VectorBase &y)
 
double predict (const double x) const
 
double s2 (void) const
 
double standard_error2 (const double x) const
 
double chisq (void) const
 Chi-squared. More...
 
double prediction_error2 (const double x) const
 
std::ostream & print (std::ostream &os, const double min, double max, const unsigned int n) const
 print output to ostream os More...
 
double r2 (void) const
 

Protected Member Functions

double variance (void) const
 

Protected Attributes

statistics::AveragerPair ap_
 
double chisq_
 

Detailed Description

Naive Regression.

Data are modeled as $ y_i = \alpha + \epsilon_i $

Member Function Documentation

◆ chisq()

double theplu::yat::regression::OneDimensional::chisq ( void  ) const
inherited

Chi-squared.

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

◆ fit()

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

This function computes the best-fit for the naive model $ y = m $ from vectors x and y, by minimizing $ \sum{(y_i-m)^2} $.

Implements theplu::yat::regression::OneDimensional.

◆ predict()

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

The predicted value is the average $ m $

Implements theplu::yat::regression::OneDimensional.

◆ prediction_error2()

double theplu::yat::regression::OneDimensional::prediction_error2 ( const double  x) const
inherited

The prediction error is defined as the expected squared deviation a new data point will have from value the model provides: $ E(Y|x - \hat{y}(x))^2 $ 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 $.

Returns
expected squared prediction error for a new data point in x

◆ print()

std::ostream& theplu::yat::regression::OneDimensional::print ( std::ostream &  os,
const double  min,
double  max,
const unsigned int  n 
) const
inherited

print output to ostream os

Printing estimated model to os in the points defined by min, max, and n. The values printed for each point is the x-value, the estimated y-value, and the estimated standard deviation of a new data poiunt will have from the y-value given the x-value (see prediction_error()).

Parameters
osOstream printout is sent to
nnumber of points printed
minsmallest x-value for which the model is printed
maxlargest x-value for which the model is printed

◆ r2()

double theplu::yat::regression::OneDimensional::r2 ( void  ) const
inherited

r2 is defined as $ 1 - \frac{Var(Y|x)}{Var(Y)} $ or the fraction of the variance explained by the regression model.

See also
s2()

◆ s2()

double theplu::yat::regression::Naive::s2 ( void  ) const
virtual

$ \frac{\sum \epsilon_i^2}{N-1} $

Returns
Conditional variance

Implements theplu::yat::regression::OneDimensional.

◆ standard_error2()

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

$ \frac{s^2}{N} $

Returns
squared standard error
See also
statistics::Averager

Implements theplu::yat::regression::OneDimensional.

◆ variance()

double theplu::yat::regression::OneDimensional::variance ( void  ) const
protectedinherited

Variance of y

Member Data Documentation

◆ ap_

statistics::AveragerPair theplu::yat::regression::OneDimensional::ap_
protectedinherited

Averager for pair of x and y

◆ chisq_

double theplu::yat::regression::OneDimensional::chisq_
protectedinherited
See also
chisq()

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

Generated on Wed Jan 25 2023 03:34:29 for yat by  doxygen 1.8.14