Does not inherit
confidenceInterval() operator=() |
RWLinearRegressionParam() standardError() |
tStatistic() tStatisticCriticalValue() |
tStatisticPvalue() value() |
#include <rw/analytics/linregparam.h> double paramValue = 0.0; double stdErr = 1.0; int degFreedom = 5; RWLinearRegressionParam regparam(paramValue, stdErr, degFreedom);
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.
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++ ) { cout << "Model parameter " << i << (i==0UL?" Intercept:":":") << endl; cout << " 99% confidence interval: " << "[" << params[i].confidenceInterval(0.01).lowerBound() << ", " << params[i].confidenceInterval(0.01).upperBound() << "]\n" << endl; } return 0; }
RWLinearRegressionParam();
Constructs an empty linear regression parameter object. Behavior undefined.
RWLinearRegressionParam(double val, double stderr, int degrees);
Constructs a Student T distribution for a linear regression parameter that has mean val, standard deviation stderr, and degrees of freedom equal to degrees.
RWLinearRegressionParam(const RWLinearRegressionParam& a);
Constructs a copy of a.
RWInterval<double> confidenceInterval(double alpha) const;
Returns an alpha level confidence interval for the parameter.
double standardError() const;
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 tStatistic(double testval=0.0) const;
Returns the t-test for the hypothesis that the parameter is equal to testval.
double tStatisticCriticalValue(double alpha) const;
Returns the absolute value v 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 tStatisticPvalue(double testval=0) const;
Returns the P-value for the parameter t statistic under the hypothesis that the parameter is equal to testval.
double value() const;
Returns the least squares estimate for the parameter.
RWLinearRegressionParam& operator=(const RWLinearRegressionParam& p);
Copies the contents of p to self.
© 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.