OpenMS
2.5.0
|
This class offers functions to perform least-squares fits to a straight line model, . More...
#include <OpenMS/MATH/STATISTICS/LinearRegression.h>
Public Member Functions | |
LinearRegression () | |
Constructor. More... | |
virtual | ~LinearRegression () |
Destructor. More... | |
template<typename Iterator > | |
void | computeRegression (double confidence_interval_P, Iterator x_begin, Iterator x_end, Iterator y_begin, bool compute_goodness=true) |
This function computes the best-fit linear regression coefficients of the model for the dataset . More... | |
template<typename Iterator > | |
void | computeRegressionWeighted (double confidence_interval_P, Iterator x_begin, Iterator x_end, Iterator y_begin, Iterator w_begin, bool compute_goodness=true) |
This function computes the best-fit linear regression coefficients of the model for the weighted dataset . More... | |
double | getIntercept () const |
Non-mutable access to the y-intercept of the straight line. More... | |
double | getSlope () const |
Non-mutable access to the slope of the straight line. More... | |
double | getXIntercept () const |
Non-mutable access to the x-intercept of the straight line. More... | |
double | getLower () const |
Non-mutable access to the lower border of confidence interval. More... | |
double | getUpper () const |
Non-mutable access to the upper border of confidence interval. More... | |
double | getTValue () const |
Non-mutable access to the value of the t-distribution. More... | |
double | getRSquared () const |
Non-mutable access to the squared Pearson coefficient. More... | |
double | getStandDevRes () const |
Non-mutable access to the standard deviation of the residuals. More... | |
double | getMeanRes () const |
Non-mutable access to the residual mean. More... | |
double | getStandErrSlope () const |
Non-mutable access to the standard error of the slope. More... | |
double | getChiSquared () const |
Non-mutable access to the chi squared value. More... | |
double | getRSD () const |
Non-mutable access to relative standard deviation. More... | |
Protected Member Functions | |
void | computeGoodness_ (const std::vector< Wm5::Vector2d > &points, double confidence_interval_P) |
Computes the goodness of the fitted regression line. More... | |
template<typename Iterator > | |
double | computeChiSquare (Iterator x_begin, Iterator x_end, Iterator y_begin, double slope, double intercept) |
Compute the chi squared of a linear fit. More... | |
template<typename Iterator > | |
double | computeWeightedChiSquare (Iterator x_begin, Iterator x_end, Iterator y_begin, Iterator w_begin, double slope, double intercept) |
Compute the chi squared of a weighted linear fit. More... | |
Protected Attributes | |
double | intercept_ |
The intercept of the fitted line with the y-axis. More... | |
double | slope_ |
The slope of the fitted line. More... | |
double | x_intercept_ |
The intercept of the fitted line with the x-axis. More... | |
double | lower_ |
The lower bound of the confidence interval. More... | |
double | upper_ |
The upper bound of the confidence interval. More... | |
double | t_star_ |
The value of the t-statistic. More... | |
double | r_squared_ |
The squared correlation coefficient (Pearson) More... | |
double | stand_dev_residuals_ |
The standard deviation of the residuals. More... | |
double | mean_residuals_ |
Mean of residuals. More... | |
double | stand_error_slope_ |
The standard error of the slope. More... | |
double | chi_squared_ |
The value of the Chi Squared statistic. More... | |
double | rsd_ |
the relative standard deviation More... | |
Private Member Functions | |
LinearRegression (const LinearRegression &arg) | |
Not implemented. More... | |
LinearRegression & | operator= (const LinearRegression &arg) |
Not implemented. More... | |
This class offers functions to perform least-squares fits to a straight line model, .
Next to the intercept with the y-axis and the slope of the fitted line, this class computes the:
|
inline |
Constructor.
|
inlinevirtual |
Destructor.
|
private |
Not implemented.
|
protected |
Compute the chi squared of a linear fit.
Referenced by LinearRegression::computeRegression().
|
protected |
Computes the goodness of the fitted regression line.
Referenced by LinearRegression::computeRegression(), and LinearRegression::computeRegressionWeighted().
void computeRegression | ( | double | confidence_interval_P, |
Iterator | x_begin, | ||
Iterator | x_end, | ||
Iterator | y_begin, | ||
bool | compute_goodness = true |
||
) |
This function computes the best-fit linear regression coefficients of the model for the dataset .
The values in x-dimension of the dataset 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.
confidence_interval_P | Value between 0-1 to determine lower and upper CI borders. |
x_begin | Begin iterator of x values |
x_end | End iterator of x values |
y_begin | Begin iterator of y values (same length as x) |
compute_goodness | Compute meta stats about the fit. If this is not done, none of the members (except slope and intercept) are meaningful. |
Exception::UnableToFit | is thrown if fitting cannot be performed |
References LinearRegression::chi_squared_, LinearRegression::computeChiSquare(), LinearRegression::computeGoodness_(), LinearRegression::intercept_, OpenMS::Math::iteratorRange2Wm5Vectors(), and LinearRegression::slope_.
void computeRegressionWeighted | ( | double | confidence_interval_P, |
Iterator | x_begin, | ||
Iterator | x_end, | ||
Iterator | y_begin, | ||
Iterator | w_begin, | ||
bool | compute_goodness = true |
||
) |
This function computes the best-fit linear regression coefficients of the model for the weighted dataset .
The values in x-dimension of the dataset 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.
confidence_interval_P | Value between 0-1 to determine lower and upper CI borders. |
x_begin | Begin iterator of x values |
x_end | End iterator of x values |
y_begin | Begin iterator of y values (same length as x) |
w_begin | Begin iterator of weight values (same length as x) |
compute_goodness | Compute meta stats about the fit. If this is not done, none of the members (except slope and intercept) are meaningful. |
Exception::UnableToFit | is thrown if fitting cannot be performed |
References LinearRegression::chi_squared_, LinearRegression::computeGoodness_(), LinearRegression::computeWeightedChiSquare(), LinearRegression::intercept_, OpenMS::Math::iteratorRange2Wm5Vectors(), and LinearRegression::slope_.
|
protected |
Compute the chi squared of a weighted linear fit.
Referenced by LinearRegression::computeRegressionWeighted().
double getChiSquared | ( | ) | const |
Non-mutable access to the chi squared value.
double getIntercept | ( | ) | const |
Non-mutable access to the y-intercept of the straight line.
double getLower | ( | ) | const |
Non-mutable access to the lower border of confidence interval.
double getMeanRes | ( | ) | const |
Non-mutable access to the residual mean.
double getRSD | ( | ) | const |
Non-mutable access to relative standard deviation.
double getRSquared | ( | ) | const |
Non-mutable access to the squared Pearson coefficient.
double getSlope | ( | ) | const |
Non-mutable access to the slope of the straight line.
double getStandDevRes | ( | ) | const |
Non-mutable access to the standard deviation of the residuals.
double getStandErrSlope | ( | ) | const |
Non-mutable access to the standard error of the slope.
double getTValue | ( | ) | const |
Non-mutable access to the value of the t-distribution.
double getUpper | ( | ) | const |
Non-mutable access to the upper border of confidence interval.
double getXIntercept | ( | ) | const |
Non-mutable access to the x-intercept of the straight line.
|
private |
Not implemented.
|
protected |
The value of the Chi Squared statistic.
Referenced by LinearRegression::computeRegression(), and LinearRegression::computeRegressionWeighted().
|
protected |
The intercept of the fitted line with the y-axis.
Referenced by LinearRegression::computeRegression(), and LinearRegression::computeRegressionWeighted().
|
protected |
The lower bound of the confidence interval.
|
protected |
Mean of residuals.
|
protected |
The squared correlation coefficient (Pearson)
|
protected |
the relative standard deviation
|
protected |
The slope of the fitted line.
Referenced by LinearRegression::computeRegression(), and LinearRegression::computeRegressionWeighted().
|
protected |
The standard deviation of the residuals.
|
protected |
The standard error of the slope.
|
protected |
The value of the t-statistic.
|
protected |
The upper bound of the confidence interval.
|
protected |
The intercept of the fitted line with the x-axis.