SourcePro C++ 12.0 |
SourcePro® C++ API Reference Guide |
SourcePro C++ Documentation Home |
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) | |
double | standardError () const |
double | value () const |
double | tStatistic (double testval=0.0) const |
double | tStatisticPValue (double testval=0.0) const |
double | tStatisticCriticalValue (double alpha) const |
RWInterval< double > | confidenceInterval (double alpha) const |
RWLinearRegressionParam & | operator= (const RWLinearRegressionParam &p) |
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.
#include <rw/analytics/linregparam.h> double paramValue = 0.0; double stdErr = 1.0; int degFreedom = 5; RWLinearRegressionParam regparam(paramValue, stdErr, degFreedom);
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); 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; }
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.
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:
where:
is equal to the pth diagonal term of the matrix
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 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.