SourcePro® API Reference Guide

 
Loading...
Searching...
No Matches
RWLinearRegressionFTest Class Reference

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 RWLinearRegression &lr)
 
 RWLinearRegressionFTest (const RWLinearRegression &lr, const RWGenMat< double > &A, const RWMathVec< double > &c)
 
 RWLinearRegressionFTest (const RWLinearRegressionFTest &t)
 
double criticalValue (double alpha) const
 
double FStatisticPValue () const
 
double FStatisticValue () const
 
RWLinearRegressionFTestoperator= (const RWLinearRegressionFTest &ft)
 
bool reject (double alpha=.05) const
 
void setHypothesis (const RWGenMat< double > &A, const RWMathVec< double > &c)
 
void setLinearRegression (const RWLinearRegression &lr)
 

Detailed Description

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.

Synopsis
#include <rw/analytics/linregress.h>
#include <rw/analytics/lrftest.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
Tests that the estimated parameters in a linear regression model are equal to a hypothesized vector o...
Definition lrftest.h:88
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

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 <iostream>
#include <lrftest.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);
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;
}

Constructor & Destructor Documentation

◆ RWLinearRegressionFTest() [1/4]

RWLinearRegressionFTest::RWLinearRegressionFTest ( )

Constructs an empty F test object. Behavior is undefined.

◆ RWLinearRegressionFTest() [2/4]

RWLinearRegressionFTest::RWLinearRegressionFTest ( const RWLinearRegressionFTest & t)

Constructs a copy of t.

◆ RWLinearRegressionFTest() [3/4]

RWLinearRegressionFTest::RWLinearRegressionFTest ( const RWLinearRegression & lr)

Constructs an F test for the hypothesis that \(\beta_1 = \beta_2 = ..\beta_p = 0\)

◆ RWLinearRegressionFTest() [4/4]

RWLinearRegressionFTest::RWLinearRegressionFTest ( const RWLinearRegression & lr,
const RWGenMat< double > & A,
const RWMathVec< double > & c )

Constructs an F test for the hypothesis that \(A\beta = c\)

Member Function Documentation

◆ criticalValue()

double RWLinearRegressionFTest::criticalValue ( double alpha) const
inline

Returns the critical value for the test at the significance level alpha.

◆ FStatisticPValue()

double RWLinearRegressionFTest::FStatisticPValue ( ) const
inline

Returns the P-value for the test.

◆ FStatisticValue()

double RWLinearRegressionFTest::FStatisticValue ( ) const
inline

Returns the value of the F statistic.

◆ operator=()

RWLinearRegressionFTest & RWLinearRegressionFTest::operator= ( const RWLinearRegressionFTest & ft)

Copies the contents of ft to self.

◆ reject()

bool RWLinearRegressionFTest::reject ( double alpha = .05) const
inline

Returns true if the hypothesis being tested will be rejected at the significance level alpha.

◆ setHypothesis()

void RWLinearRegressionFTest::setHypothesis ( const RWGenMat< double > & A,
const RWMathVec< double > & c )

Sets the hypothesis being tested to \(A\beta = c\)

◆ setLinearRegression()

void RWLinearRegressionFTest::setLinearRegression ( const RWLinearRegression & lr)

Sets the linear regression for which the hypothesis will be tested.

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