SourcePro C++ 12.0 |
SourcePro® C++ API Reference Guide |
SourcePro C++ Documentation Home |
Tests that the estimated parameters in a linear regression model are equal to a hypothesized vector of values. More...
#include <rw/analytics/lrftest.h>
Public Member Functions | |
RWLinearRegressionFTest () | |
RWLinearRegressionFTest (const RWLinearRegressionFTest &t) | |
RWLinearRegressionFTest (const RWLinearRegression &lr) | |
RWLinearRegressionFTest (const RWLinearRegression &lr, const RWGenMat< double > &A, const RWMathVec< double > &c) | |
double | FStatisticValue () const |
double | FStatisticPValue () const |
double | criticalValue (double alpha) const |
bool | reject (double alpha=.05) const |
void | setLinearRegression (const RWLinearRegression &lr) |
void | setHypothesis (const RWGenMat< double > &A, const RWMathVec< double > &c) |
RWLinearRegressionFTest & | operator= (const RWLinearRegressionFTest &ft) |
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 the section "Multiple Linear Regression," in the Business Analysis Module User's Guide.
#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);
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> #include <iostream> 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); RWLinearRegressionFTest FTest(lr); std::cout << " f statistic value: " << FTest.FStatisticValue() << std::endl; std::cout << " f statistic P-value: " << FTest.FStatisticPValue() << std::endl; std::cout << " 99% Critical value: " << FTest.criticalValue(0.01) << std::endl; if ( FTest.reject(0.01) ) { std::cout << "Reject H0 at significance level 0.01" << std::endl; } else { std::cout << "Fail to reject H0 at significance level 0.01" << std::endl; } return 0; }
RWLinearRegressionFTest::RWLinearRegressionFTest | ( | ) |
Constructs an empty F test object. Behavior is undefined.
RWLinearRegressionFTest::RWLinearRegressionFTest | ( | const RWLinearRegressionFTest & | t | ) |
Constructs a copy of t.
RWLinearRegressionFTest::RWLinearRegressionFTest | ( | const RWLinearRegression & | lr | ) |
Constructs an F test for the hypothesis that
RWLinearRegressionFTest::RWLinearRegressionFTest | ( | const RWLinearRegression & | lr, | |
const RWGenMat< double > & | A, | |||
const RWMathVec< double > & | c | |||
) |
Constructs an F test for the hypothesis that
double RWLinearRegressionFTest::criticalValue | ( | double | alpha | ) | const [inline] |
Returns the critical value for the test at the significance level alpha.
double RWLinearRegressionFTest::FStatisticPValue | ( | ) | const [inline] |
Returns the P-value for the test.
double RWLinearRegressionFTest::FStatisticValue | ( | ) | const [inline] |
Returns the value of the F statistic.
RWLinearRegressionFTest& RWLinearRegressionFTest::operator= | ( | const RWLinearRegressionFTest & | ft | ) |
Copies the contents of ft to self.
bool RWLinearRegressionFTest::reject | ( | double | alpha = .05 |
) | const [inline] |
Returns true
if the hypothesis being tested will be rejected at the significance level alpha.
void RWLinearRegressionFTest::setHypothesis | ( | const RWGenMat< double > & | A, | |
const RWMathVec< double > & | c | |||
) |
Sets the hypothesis being tested to
void RWLinearRegressionFTest::setLinearRegression | ( | const RWLinearRegression & | lr | ) |
Sets the linear regression for which the hypothesis will be tested.
© 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.