Does not inherit
#include <rw/math/genmat.h> #include <rw/math/mathvec.h> #include <rw/analytics/linregress.h> #include <rw/analytics/lranova.h> RWGenMat<double> predictorMatrix; RWMathVec<double> observationVector; RWLinearRegression lr(predictorMatrix, observationVector); RWLinearRegressionANOVA anova(lr);
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.
#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); RWLinearRegressionANOVA lranova(lr); 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; }
RWLinearRegressionANOVA();
Constructs an empty ANOVA object. Behavior undefined.
RWLinearRegressionANOVA(const RWLinearRegressionANOVA& a);
Constructs a copy of a.
RWLinearRegressionANOVA(const RWLinearRegression& lr);
Constructs an ANOVA object for the linear regression lr.
double adjRSquare() const;
Returns the adjusted coefficient of determination as defined by the following formula:
double FStatistic() const;
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.
double FStatisticCriticalValue(double alpha=.05) const;
Returns the alpha level critical value for the overall F statistic.
double FStatisticPValue() const;
Returns the P-value for the overall F statistic.
double meanSquareRegression() const;
Returns the quotient of the regression sum of squares and the number of degrees of freedom for the regression.
double meanSquareResidual() const;
Returns the quotient of the residual sum of squares, RSS, and the number of degrees of freedom for the model.
int residualDegreesOfFreedom() const;
Returns the residual degrees of freedom, defined as the number of observations minus the number of parameters.
void setLinearRegression(const RWLinearRegression& lr);
Sets the linear regression for which the analysis of variance is to be performed.
int regressionDegreesOfFreedom() const;
Returns the number of degrees of freedom for the model, defined as 1 less than the number of parameters in the model.
double residualSumOfSquares() const;
Returns the quantity RSS as defined by
double regressionSumOfSquares() const;
Returns the quantity , where
double RSquare() const;
Returns the coefficient of determination as defined by the following formula:
RWLinearRegressionANOVA& operator=(const RWLinearRegressionANOVA& lra);
Copies the contents of lra to self.
© Copyright Rogue Wave Software, Inc. All Rights Reserved.
Rogue Wave and SourcePro are registered trademarks of Rogue Wave Software, Inc. in the United States and other countries. All other trademarks are the property of their respective owners.
Contact Rogue Wave about documentation or support issues.