>
Member Functions | |||
criticalValue() FStatisticPValue() |
FStatisticValue() operator=() |
reject() setHypothesis() |
setLinearRegression() |
>#include <rw/math/genmat.h> #include <rw/math/mathvec.h> #include <rw/analytics/linregress.h> #include <rw/analytics/lrftest.h> RWGenMat<double> predictorMatrix; RWMathVec<double> observationVector; RWLinearRegression lr(predictorMatrix, observationVector); RWLinearRegressionFTest ftest(lr);
Class RWLinearRegressionFTest can be used to test that the estimated parameters in a linear regression model are equal to a hypothesized vector of values. For example, it can test the hypothesis that all parameters are equal to 0. To be completely precise, the class tests the hypothesis that the estimated parameters are the solution to some specified system of linear equations. The test is based on the F statistic described in Section 3.2.4.
>The following example creates a linear regression object and tests the hypothesis that all parameters are equal to 0 at a confidence level of
99 percent.
#include <rw/analytics/linregress.h> #include <lrftest.h> 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); RWLinearRegressionFTest FTest(lr); cout << " f statistic value: " << FTest.FStatisticValue() << endl; cout << " f statistic P-value: " << FTest.FStatisticPValue() << endl; cout << " 99% Critical value: " << FTest.criticalValue(0.01) << endl; if ( FTest.reject(0.01) ) { cout << "Reject H0 at significance level 0.01" << endl; } else { cout << "Fail to reject H0 at significance level 0.01" << endl; } return 0; }>
RWLinearRegressionFTest();
Constructs an empty F test object. Behavior is undefined.
RWLinearRegressionFTest(const RWLinearRegressionFTest<T>& t);
Constructs a copy of t.
RWLinearRegressionFTest(const RWLinearRegression<T>& lr);
Constructs an F test for the hypothesis that .
RWLinearRegressionFTest(const RWLinearRegression& lr, const RWGenMat<double>& A, const RWMathVec<double>& c);
Constructs an F test for the hypothesis that .
double criticalValue(double alpha) const;
Returns the critical value for the test at the significance level alpha.
double FStatisticPValue() const;
Returns the P-value for the test.
double FStatisticValue() const;
Returns the value of the F statistic.
RWBoolean reject(double alpha=.05);
Returns TRUE if the hypothesis being tested will be rejected at the significance level alpha.
void setHypothesis(const RWGenMat<double>& A, const RWMathVec<double>& c);
Sets the hypothesis being tested to .
void setLinearRegression(const RWLinearRegression& lr);
Sets the linear regression for which the hypothesis will be tested.
RWLinearRegressionFTest& operator=(const RWLinearRegressionFTest& ft);
Copies the contents of ft to self.
©Copyright 1999, Rogue Wave Software, Inc.
Send mail to report errors or comment on the documentation.