Home  · Classes  · Annotated Classes  · Modules  · Members  · Namespaces  · Related Pages
Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions

LinearRegression Class Reference
[Math]

This class offers functions to perform least-squares fits to a straight line model, $ Y(c,x) = c_0 + c_1 x $. More...

#include <OpenMS/MATH/STATISTICS/LinearRegression.h>

List of all members.

Public Member Functions

 LinearRegression ()
 Constructor.
virtual ~LinearRegression ()
 Destructor.
template<typename Iterator >
void computeRegression (double confidence_interval_P, Iterator x_begin, Iterator x_end, Iterator y_begin)
 This function 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) $.
template<typename Iterator >
void computeRegressionNoIntercept (double confidence_interval_P, Iterator x_begin, Iterator x_end, Iterator y_begin)
 This function computes the best-fit linear regression coefficient $ (c_0) $ of the model $ Y = c_1 X $ for the dataset $ (x, y) $.
template<typename Iterator >
void computeRegressionWeighted (double confidence_interval_P, Iterator x_begin, Iterator x_end, Iterator y_begin, Iterator w_begin)
 This function computes the best-fit linear regression coefficients $ (c_0,c_1) $ of the model $ Y = c_0 + c_1 X $ for the weighted dataset $ (x, y) $.
DoubleReal getIntercept () const
 Non-mutable access to the y-intercept of the straight line.
DoubleReal getSlope () const
 Non-mutable access to the slope of the straight line.
DoubleReal getXIntercept () const
 Non-mutable access to the x-intercept of the straight line.
DoubleReal getLower () const
 Non-mutable access to the lower border of confidence interval.
DoubleReal getUpper () const
 Non-mutable access to the upper border of confidence interval.
DoubleReal getTValue () const
 Non-mutable access to the value of the t-distribution.
DoubleReal getRSquared () const
 Non-mutable access to the squared pearson coefficient.
DoubleReal getStandDevRes () const
 Non-mutable access to the standard deviation of the residuals.
DoubleReal getMeanRes () const
 Non-mutable access to the residual mean.
DoubleReal getStandErrSlope () const
 Non-mutable access to the standard error of the slope.
DoubleReal getChiSquared () const
 Non-mutable access to the chi squared value.
DoubleReal getRSD () const
 Non-mutable access to relelative standard deviation.

Protected Member Functions

void computeGoodness_ (double *X, double *Y, int N, double confidence_interval_P)
 Computes the goodness of the fitted regression line.
template<typename Iterator >
void iteratorRange2Arrays_ (Iterator x_begin, Iterator x_end, Iterator y_begin, double *x_array, double *y_array)
 Copies the distance(x_begin,x_end) elements starting at x_begin and y_begin into the arrays x_array and y_array.
template<typename Iterator >
void iteratorRange3Arrays_ (Iterator x_begin, Iterator x_end, Iterator y_begin, Iterator w_begin, double *x_array, double *y_array, double *w_array)
 Copy the distance(x_begin,x_end) elements starting at x_begin, y_begin and w_begin into the arrays x_array, y_array and w_array.

Protected Attributes

double intercept_
 The intercept of the fitted line with the y-axis.
double slope_
 The slope of the fitted line.
double x_intercept_
 The intercept of the fitted line with the x-axis.
double lower_
 The lower bound of the confidence intervall.
double upper_
 The upper bound of the confidence intervall.
double t_star_
 The value of the t-statistic.
double r_squared_
 The squared correlation coefficient (Pearson).
double stand_dev_residuals_
 The standard deviation of the residuals.
double mean_residuals_
 Mean of residuals.
double stand_error_slope_
 The standard error of the slope.
double chi_squared_
 The value of the Chi Squared statistic.
double rsd_
 the relative standard deviation

Private Member Functions

 LinearRegression (const LinearRegression &arg)
 Not implemented.
LinearRegressionoperator= (const LinearRegression &arg)
 Not implemented.

Detailed Description

This class offers functions to perform least-squares fits to a straight line model, $ Y(c,x) = c_0 + c_1 x $.

It capsulates the GSL methods for a weighted and an unweighted linear regression.

Next to the intercept with the y-axis and the slope of the fitted line, this class computes the:


Constructor & Destructor Documentation

LinearRegression (  )  [inline]

Constructor.

virtual ~LinearRegression (  )  [inline, virtual]

Destructor.

LinearRegression ( const LinearRegression arg  )  [private]

Not implemented.


Member Function Documentation

void computeGoodness_ ( double X,
double Y,
int  N,
double  confidence_interval_P 
) [protected]
void computeRegression ( double  confidence_interval_P,
Iterator  x_begin,
Iterator  x_end,
Iterator  y_begin 
)

This function 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) $.

The values in x-dimension of the dataset $ (x,y) $ are given by the iterator range [x_begin,x_end) and the corresponding y-values start at position y_begin.

For a "x %" Confidence Interval use confidence_interval_P = x/100. For example the 95% Confidence Interval is supposed to be an interval that has a 95% chance of containing the true value of the parameter.

Returns:
If an error occured during the fit.
Exceptions:
Exception::UnableToFit is thrown if fitting cannot be performed

References LinearRegression::chi_squared_, LinearRegression::computeGoodness_(), LinearRegression::intercept_, LinearRegression::iteratorRange2Arrays_(), and LinearRegression::slope_.

void computeRegressionNoIntercept ( double  confidence_interval_P,
Iterator  x_begin,
Iterator  x_end,
Iterator  y_begin 
)

This function computes the best-fit linear regression coefficient $ (c_0) $ of the model $ Y = c_1 X $ for the dataset $ (x, y) $.

The values in x-dimension of the dataset $ (x,y) $ are given by the iterator range [x_begin,x_end) and the corresponding y-values start at position y_begin.

For a "x %" Confidence Interval use confidence_interval_P = x/100. For example the 95% Confidence Interval is supposed to be an interval that has a 95% chance of containing the true value of the parameter.

Returns:
If an error occured during the fit.
Exceptions:
Exception::UnableToFit is thrown if fitting cannot be performed

References LinearRegression::chi_squared_, LinearRegression::computeGoodness_(), LinearRegression::intercept_, LinearRegression::iteratorRange2Arrays_(), and LinearRegression::slope_.

void computeRegressionWeighted ( double  confidence_interval_P,
Iterator  x_begin,
Iterator  x_end,
Iterator  y_begin,
Iterator  w_begin 
)

This function computes the best-fit linear regression coefficients $ (c_0,c_1) $ of the model $ Y = c_0 + c_1 X $ for the weighted dataset $ (x, y) $.

The values in x-dimension of the dataset $ (x, y) $ are given by the iterator range [x_begin,x_end) and the corresponding y-values start at position y_begin. They will be weighted by the values starting at w_begin.

For a "x %" Confidence Interval use confidence_interval_P = x/100. For example the 95% Confidence Interval is supposed to be an interval that has a 95% chance of containing the true value of the parameter.

Returns:
If an error occured during the fit.
Exceptions:
Exception::UnableToFit is thrown if fitting cannot be performed

References LinearRegression::chi_squared_, LinearRegression::computeGoodness_(), LinearRegression::intercept_, LinearRegression::iteratorRange3Arrays_(), and LinearRegression::slope_.

DoubleReal getChiSquared (  )  const

Non-mutable access to the chi squared value.

DoubleReal getIntercept (  )  const

Non-mutable access to the y-intercept of the straight line.

DoubleReal getLower (  )  const

Non-mutable access to the lower border of confidence interval.

DoubleReal getMeanRes (  )  const

Non-mutable access to the residual mean.

DoubleReal getRSD (  )  const

Non-mutable access to relelative standard deviation.

DoubleReal getRSquared (  )  const

Non-mutable access to the squared pearson coefficient.

DoubleReal getSlope (  )  const

Non-mutable access to the slope of the straight line.

DoubleReal getStandDevRes (  )  const

Non-mutable access to the standard deviation of the residuals.

DoubleReal getStandErrSlope (  )  const

Non-mutable access to the standard error of the slope.

DoubleReal getTValue (  )  const

Non-mutable access to the value of the t-distribution.

DoubleReal getUpper (  )  const

Non-mutable access to the upper border of confidence interval.

DoubleReal getXIntercept (  )  const

Non-mutable access to the x-intercept of the straight line.

void iteratorRange2Arrays_ ( Iterator  x_begin,
Iterator  x_end,
Iterator  y_begin,
double x_array,
double y_array 
) [protected]

Copies the distance(x_begin,x_end) elements starting at x_begin and y_begin into the arrays x_array and y_array.

Referenced by LinearRegression::computeRegression(), and LinearRegression::computeRegressionNoIntercept().

void iteratorRange3Arrays_ ( Iterator  x_begin,
Iterator  x_end,
Iterator  y_begin,
Iterator  w_begin,
double x_array,
double y_array,
double w_array 
) [protected]

Copy the distance(x_begin,x_end) elements starting at x_begin, y_begin and w_begin into the arrays x_array, y_array and w_array.

Referenced by LinearRegression::computeRegressionWeighted().

LinearRegression& operator= ( const LinearRegression arg  )  [private]

Not implemented.


Member Data Documentation

double chi_squared_ [protected]
double intercept_ [protected]
double lower_ [protected]

The lower bound of the confidence intervall.

double mean_residuals_ [protected]

Mean of residuals.

double r_squared_ [protected]

The squared correlation coefficient (Pearson).

double rsd_ [protected]

the relative standard deviation

double slope_ [protected]

The standard deviation of the residuals.

The standard error of the slope.

double t_star_ [protected]

The value of the t-statistic.

double upper_ [protected]

The upper bound of the confidence intervall.

double x_intercept_ [protected]

The intercept of the fitted line with the x-axis.


OpenMS / TOPP release 1.10.0 Documentation generated on Thu Mar 7 2013 09:43:00 using doxygen 1.7.1