SourcePro® API Reference Guide

 
Loading...
Searching...
No Matches
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);
Models an estimated linear regression parameter using a T distribution.
Definition linregparam.h:82
Example

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

#include <rw/analytics/linregparam.h>
#include <rw/analytics/linregress.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);
RWTValVector<RWLinearRegressionParam> params = 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;
}
A templatized general matrix class.
Definition genmat.h:741
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
A value-based collection of values implemented as a vector.
Definition tvvector.h:103
size_type length() const
Definition tvvector.h:490

Constructor & Destructor Documentation

◆ RWLinearRegressionParam() [1/3]

RWLinearRegressionParam::RWLinearRegressionParam ( )
inline

Constructs an empty linear regression parameter object. Behavior undefined.

◆ RWLinearRegressionParam() [2/3]

RWLinearRegressionParam::RWLinearRegressionParam ( const RWLinearRegressionParam & p)
inline

Constructs a copy of p.

◆ RWLinearRegressionParam() [3/3]

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

◆ confidenceInterval()

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

Returns an alpha level confidence interval for the parameter.

◆ operator=()

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

Copies the contents of p to self.

◆ standardError()

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.

◆ tStatistic()

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

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

◆ tStatisticCriticalValue()

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.

◆ tStatisticPValue()

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.

◆ value()

double RWLinearRegressionParam::value ( ) const
inline

Returns the least squares estimate for the parameter.

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