Result of linear regression. More...
#include <LinearRegression.hpp>
Public Member Functions | |
double | var_y () const |
Estimated variance of observations Y, equal to rss / dof . | |
double | r2 () const |
R2 coefficient. More... | |
double | adjusted_r2 () const |
Adjusted R2 coefficient. More... | |
Public Attributes | |
unsigned int | n |
unsigned int | dof |
double | rss |
double | tss |
Result of linear regression.
Supports R2 calculated w/r to a "base model" returning average Y. R2 is defined as 1 - RSS / TSS, where RSS is the residual sum of squares for the fitted model:
\( \sum_{i=1}^N (\hat{y}_i - y_i)^2 \)
and TSS is the RSS for the "base model":
\( \mathrm{TSS} = \sum_{i=1}^N (y_i - N^{-1} \sum_{j=1}^N y_j)^2 \).
|
inline |
R2 coefficient.
1 - fraction of variance unexplained relative to a "base model" (returning average Y), estimated as population variance. Equal to 1 - rss / tss
.
|
inline |
Adjusted R2 coefficient.
1 - fraction of variance unexplained relative to a "base model" (returning average Y), estimated as sample variance. Equal to 1 - (rss / dof) / (tss / (n - 1))
.
unsigned int ml::LinearRegression::Result::n |
Number of data points.
unsigned int ml::LinearRegression::Result::dof |
Number of residual degrees of freedom (e.g. n - 2
or n - 1
for univariate regression with or without intercept).
double ml::LinearRegression::Result::rss |
Residual sum of squares (RSS).
double ml::LinearRegression::Result::tss |
Total sum of squares (TSS, equal to the RSS for the "base model" always returning average Y).