SourcePro® API Reference Guide

 
Loading...
Searching...
No Matches
RWLinearRegressionANOVA Class Reference

Provides information on the variance of residual errors for a linear regression model. More...

#include <rw/analytics/lranova.h>

Public Member Functions

 RWLinearRegressionANOVA ()
 
 RWLinearRegressionANOVA (const RWLinearRegression &lr)
 
 RWLinearRegressionANOVA (const RWLinearRegressionANOVA &a)
 
double adjRSquare () const
 
double FStatistic () const
 
double FStatisticCriticalValue (double alpha=.05) const
 
double FStatisticPValue () const
 
double meanSquareRegression () const
 
double meanSquareResidual () const
 
RWLinearRegressionANOVAoperator= (const RWLinearRegressionANOVA &lra)
 
int regressionDegreesOfFreedom () const
 
double regressionSumOfSquares () const
 
int residualDegreesOfFreedom () const
 
double residualSumOfSquares () const
 
double RSquare () const
 
void setLinearRegression (const RWLinearRegression &lr)
 

Detailed Description

ANOVA stands for analysis of variance. For the Linear Algebra Module class RWLinearRegressionANOVA, the analyzed variance is the variance of residual errors in a linear regression model, also known as the regression's goodness of fit.

Once an instance of RWLinearRegressionANOVA is constructed with a linear regression model, it can be queried for values related to goodness of fit, including the residual sum of squares, the coefficient of determination, and the F statistic.

Synopsis
#include <rw/analytics/linregress.h>
#include <rw/analytics/lranova.h>
#include <rw/math/genmat.h>
#include <rw/math/mathvec.h>
RWGenMat<double> predictorMatrix;
RWMathVec<double> observationVector;
RWLinearRegression lr(predictorMatrix, observationVector);
A templatized general matrix class.
Definition genmat.h:741
Provides information on the variance of residual errors for a linear regression model.
Definition lranova.h:77
Constructs a linear regression model from a matrix of predictor variable data and a vector of observa...
Definition linregress.h:96
A templatized vector class.
Definition mathvec.h:667
Example
#include <rw/analytics/linregress.h>
#include <rw/analytics/lranova.h>
int main() {
RWGenMat<double> predictorMatrix =
"5x2 [1.2 2.1 8 7 3 3.2 6.4 4.6 2 2.3]";
RWMathVec<double> observationVector = "[2.5 3.7 1.4 2.3 5.6]";
RWLinearRegression lr(predictorMatrix, observationVector);
cout << "f statistic: " << lranova.FStatistic() << endl;
cout << "f statistic P-value: " << lranova.FStatisticPValue()
<< endl;
cout << "mean square residual " << lranova.meanSquareResidual()
<< endl;
cout << "mean square regression " << lranova.meanSquareRegression()
<< endl;
cout << "Rsquare: " << lranova.RSquare() << endl;
cout << "adjusted Rsquare: " << lranova.adjRSquare() << endl;
return 0;
}

Constructor & Destructor Documentation

◆ RWLinearRegressionANOVA() [1/3]

RWLinearRegressionANOVA::RWLinearRegressionANOVA ( )

Constructs an empty ANOVA object. Behavior undefined.

◆ RWLinearRegressionANOVA() [2/3]

RWLinearRegressionANOVA::RWLinearRegressionANOVA ( const RWLinearRegressionANOVA & a)

Constructs a copy of a.

◆ RWLinearRegressionANOVA() [3/3]

RWLinearRegressionANOVA::RWLinearRegressionANOVA ( const RWLinearRegression & lr)

Constructs an ANOVA object for the linear regression lr.

Member Function Documentation

◆ adjRSquare()

double RWLinearRegressionANOVA::adjRSquare ( ) const
inline

Returns the adjusted coefficient of determination as defined by the following formula:

\[ R_{adj}^2 = 1.0 - \frac{\displaystyle\sum_{i=1}^{n}(Y_i - \hat{Y}_i)^2 / (n - p - 2)}{\displaystyle\sum_{i=1}^{n}(Y_i - \overline{Y})^2 / (n - 1)} \]

◆ FStatistic()

double RWLinearRegressionANOVA::FStatistic ( ) const
inline

Returns the overall F statistic for the model as defined in Section 3.2, "Multiple Linear Regression," in the Business Analysis Module User's Guide.

◆ FStatisticCriticalValue()

double RWLinearRegressionANOVA::FStatisticCriticalValue ( double alpha = .05) const
inline

Returns the alpha level critical value for the overall F statistic.

◆ FStatisticPValue()

double RWLinearRegressionANOVA::FStatisticPValue ( ) const
inline

Returns the P-value for the overall F statistic.

◆ meanSquareRegression()

double RWLinearRegressionANOVA::meanSquareRegression ( ) const
inline

Returns the quotient of the regression sum of squares and the number of degrees of freedom for the regression.

◆ meanSquareResidual()

double RWLinearRegressionANOVA::meanSquareResidual ( ) const
inline

Returns the quotient of the residual sum of squares, RSS, and the number of degrees of freedom for the model.

◆ operator=()

RWLinearRegressionANOVA & RWLinearRegressionANOVA::operator= ( const RWLinearRegressionANOVA & lra)

Copies the contents of lra to self.

◆ regressionDegreesOfFreedom()

int RWLinearRegressionANOVA::regressionDegreesOfFreedom ( ) const
inline

Returns the number of degrees of freedom for the model, defined as 1 less than the number of parameters in the model.

◆ regressionSumOfSquares()

double RWLinearRegressionANOVA::regressionSumOfSquares ( ) const
inline

Returns the quantity \(\displaystyle\sum_{i=1}^{n}(\hat{Y}_i - \overline{Y})^2\) , where \(\overline{Y} = \frac{1}{n}\displaystyle\sum_{i=1}^{n}(Y_i)\)

◆ residualDegreesOfFreedom()

int RWLinearRegressionANOVA::residualDegreesOfFreedom ( ) const
inline

Returns the residual degrees of freedom, defined as the number of observations minus the number of parameters.

◆ residualSumOfSquares()

double RWLinearRegressionANOVA::residualSumOfSquares ( ) const
inline

Returns the quantity RSS as defined by

\[ RSS = \displaystyle\sum_{i=1}^{n}(Y_i - \hat{Y}_i)^2 \]

◆ RSquare()

double RWLinearRegressionANOVA::RSquare ( ) const
inline

Returns the coefficient of determination as defined by the following formula:

\[ R^2 = 1.0 - \frac{\displaystyle\sum_{i=1}^{n}(Y_i - \hat{Y}_i)^2} {\displaystyle\sum_{i=1}^{n}(Y_i - \overline{Y})^2} \]

◆ setLinearRegression()

void RWLinearRegressionANOVA::setLinearRegression ( const RWLinearRegression & lr)

Sets the linear regression for which the analysis of variance is to be performed.

Copyright © 2024 Rogue Wave Software, Inc., a Perforce company. All Rights Reserved.