SourcePro® API Reference Guide

 
List of all members | Public Member Functions
RWLinearRegressionParam Class Reference

Models an estimated linear regression parameter using a T distribution. More...

#include <rw/analytics/linregparam.h>

Public Member Functions

 RWLinearRegressionParam ()
 
 RWLinearRegressionParam (const RWLinearRegressionParam &p)
 
 RWLinearRegressionParam (double val, double err, int degrees)
 
RWInterval< double > confidenceInterval (double alpha) const
 
RWLinearRegressionParamoperator= (const RWLinearRegressionParam &p)
 
double standardError () const
 
double tStatistic (double testval=0.0) const
 
double tStatisticCriticalValue (double alpha) const
 
double tStatisticPValue (double testval=0.0) const
 
double value () const
 

Detailed Description

Class RWLinearRegressionParam models an estimated linear regression parameter using a T distribution. Once a class instance is constructed, it can be used to test some statistical hypothesis about the parameter's value.

Synopsis
#include <rw/analytics/linregparam.h>
double paramValue = 0.0;
double stdErr = 1.0;
int degFreedom = 5;
RWLinearRegressionParam regparam(paramValue, stdErr, degFreedom);
Example

The following simple example prints the 99 percent confidence intervals for all parameters in a linear regression.

#include <rw/analytics/linregress.h>
#include <rw/analytics/linregparam.h>
#include <rw/rstream.h> // Handles inclusion of 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);
lr.parameterEstimates();
for ( size_t i = 0; i < params.length(); i++ )
{
std::cout << "Model parameter " << i << (i==0UL?" Intercept:":":")
<< std::endl;
std::cout << " 99% confidence interval: " << "[" <<
params[i].confidenceInterval(0.01).lowerBound() << ", " <<
params[i].confidenceInterval(0.01).upperBound() << "]\n" <<
std::endl;
}
return 0;
}

Constructor & Destructor Documentation

RWLinearRegressionParam::RWLinearRegressionParam ( )
inline

Constructs an empty linear regression parameter object. Behavior undefined.

RWLinearRegressionParam::RWLinearRegressionParam ( const RWLinearRegressionParam p)
inline

Constructs a copy of p.

RWLinearRegressionParam::RWLinearRegressionParam ( double  val,
double  err,
int  degrees 
)
inline

Constructs a Student T distribution for a linear regression parameter that has mean val, standard deviation err, and degrees of freedom equal to degrees.

Member Function Documentation

RWInterval<double> RWLinearRegressionParam::confidenceInterval ( double  alpha) const

Returns an alpha level confidence interval for the parameter.

RWLinearRegressionParam& RWLinearRegressionParam::operator= ( const RWLinearRegressionParam p)

Copies the contents of p to self.

double RWLinearRegressionParam::standardError ( ) const
inline

Returns the estimated standard error for the estimate. The estimate for the pth parameter of a linear regression is defined by the equation:

\[ \hat{\sigma}_p = \sqrt{S^2\{(\mathbf{X'X})^{-1}\}_{pp}} \]

where:

\[ S^2 = \cfrac{(\mathbf{Y-X}\hat{\beta})'(\mathbf{Y-X}\hat{\beta})} {n-p} \]

\(\{(\mathbf{X'X})^{-1}\}_{pp}\) is equal to the pth diagonal term of the matrix \((\mathbf{X'X})^{-1}\) and n is the number of observations.

double RWLinearRegressionParam::tStatistic ( double  testval = 0.0) const
inline

Returns the t-test for the hypothesis that the parameter is equal to testval.

double RWLinearRegressionParam::tStatisticCriticalValue ( double  alpha) const
inline

Returns the absolute value for which the parameter would have to differ from testval before we would reject the hypothesis that the parameter is equal to testval at significance level alpha.

double RWLinearRegressionParam::tStatisticPValue ( double  testval = 0.0) const

Returns the P-value for the parameter t statistic under the hypothesis that the parameter is equal to testval.

double RWLinearRegressionParam::value ( ) const
inline

Returns the least squares estimate for the parameter.

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