SourcePro® 2024.1 |
SourcePro® API Reference Guide |
Constructs a linear regression model from a matrix of predictor variable data and a vector of observation variable data. More...
#include <rw/analytics/linregress.h>
Public Member Functions | |
RWLinearRegression () | |
RWLinearRegression (const RWGenMat< double > &predictorData, const RWMathVec< double > &obsVec, const RWRegressionCalc< double, double > &c, InterceptOption interceptOpt=addIntercept) | |
RWLinearRegression (const RWGenMat< double > &predictorData, const RWMathVec< double > &obsVec, InterceptOption interceptOpt=addIntercept) | |
RWLinearRegression (const RWLinearRegression &lr) | |
RWLinearRegression & | operator= (const RWLinearRegression &lr) |
RWGenMat< double > | paramDispersionMatrix () const |
RWTValVector< RWLinearRegressionParam > | parameterEstimates () const |
RWMathVec< double > | predictedObservation (const RWGenMat< double > &m) const |
double | predictedObservation (const RWMathVec< double > &v) const |
RWInterval< double > | predictionInterval (const RWMathVec< double > &x, double alpha) const |
RWMathVec< double > | residuals () const |
double | variance () const |
Public Member Functions inherited from RWRegression< double, double > | |
void | addInterceptParameter () |
void | addObservation (const RWMathVec< double > &, double) |
void | addObservations (const RWGenMat< double > &, const RWMathVec< double > &) |
void | addPredictor (const RWMathVec< double > &) |
void | addPredictors (const RWGenMat< double > &) |
const RWRegressionCalc< double, double > & | calcMethod () const |
bool | fail () const |
bool | hasInterceptParameter () const |
size_t | numObservations () const |
size_t | numParameters () const |
size_t | numPredictors () const |
RWMathVec< double > | observationVector () |
const RWMathVec< double > | observationVector () const |
const RWMathVec< double > | parameters () const |
RWGenMat< double > | predictorMatrix () |
const RWGenMat< double > | predictorMatrix () const |
void | reCalculateParameters () |
const RWGenMat< double > | regressionMatrix () const |
void | removeInterceptParameter () |
void | removeObservations (size_t startingIndex, size_t numToRemove) |
void | removePredictors (size_t startingIndex, size_t numToRemove) |
void | setCalcMethod (const RWRegressionCalc< double, double > &c, bool recalculate=true) |
void | setRegressionData (const RWGenMat< double > &r, const RWMathVec< double > &o, InterceptOption interceptOpt=addIntercept) |
Additional Inherited Members | |
Public Types inherited from RWRegression< double, double > | |
enum | InterceptOption |
Class RWLinearRegression constructs a linear regression model from a matrix of predictor variable data and a vector of observation variable data. The class implements multiple linear regression as described in Section 3.2, "Multiple Linear Regression," in the Business Analysis Module User's Guide.
The class makes several assumptions regarding the predictor matrix and observation vector passed to the constructor. Columns in the predictor matrix correspond to predictor variables, and the matrix rows correspond to predictor patterns. Both predictor matrix and observation vector are double precision, and the length of the observation vector should equal the number of rows in the predictor matrix. The user has the choice of specifying whether the model has an intercept parameter, and if so, whether the provided predictor matrix includes a column of 1s for the intercept parameter.
You can choose from among several regression parameter calculation methods, including QR decomposition without pivoting (RWLeastSqQRCalc), QR decomposition with pivoting (RWLeastSqQRPvtCalc), and singular value decomposition (RWLeastSqSVDCalc). The calculation method is set by passing a calculation class instance to the method setCalcMethod(). You have the option of providing your own implementation derived from the class RWRegressionCalc<double,double>.
Once the linear regression object is constructed, it can be queried for specific values related to linear regression, such as model parameters, model predictions, prediction intervals, and confidence intervals for parameter values. The model may also be updated by changing values in the predictor matrix and observation vector, or by changing the calculation method.
This simple example prints out the calculated parameter values for a linear regression model.
|
inline |
Constructs an empty linear regression object. Behavior is undefined.
|
inline |
Constructs a copy of lr.
|
inline |
Constructs a regression object from the given predictor data matrix and observation vector. The intercept option parameter indicates whether or not the model contains an intercept parameter. The parameter calculation is done using the QR decomposition method.
|
inline |
Constructs a regression object from the given predictor data matrix and observation vector. The intercept option parameter indicates whether or not the model contains an intercept parameter. The parameter calculation is done using the method defined by the regression calculation object c.
|
inline |
Copies the contents of lr to self.
RWGenMat< double > RWLinearRegression::paramDispersionMatrix | ( | ) | const |
Returns the dispersion matrix for the parameter estimates. This is also known as the parameter variance-covariance matrix.
RWTValVector< RWLinearRegressionParam > RWLinearRegression::parameterEstimates | ( | ) | const |
Returns the list of estimated parameters.
Returns the predicted response vector, \(\mathbf{\hat{Y}}\) , as defined in Section 3.2, "Multiple Linear Regression," in the Business Analysis Module User's Guide.
double RWLinearRegression::predictedObservation | ( | const RWMathVec< double > & | v | ) | const |
Returns the predicted response, \(\mathbf{\hat{Y}}\) , as defined in Section 3.2, "Multiple Linear Regression," in the Business Analysis Module User's Guide.
RWInterval< double > RWLinearRegression::predictionInterval | ( | const RWMathVec< double > & | x, |
double | alpha ) const |
Returns an alpha level confidence interval for the response predicted by the regression at x as defined in Section 3.2, "Multiple Linear Regression," in the Business Analysis Module User's Guide.
RWMathVec< double > RWLinearRegression::residuals | ( | ) | const |
Returns the vector of residuals \(\mathbf{e = Y - \hat{Y}}\) See Section 3.2, "Multiple Linear Regression," in the Business Analysis Module User's Guide.
double RWLinearRegression::variance | ( | ) | const |
Returns the variance for the model. This is the residual sum of squares divided by its degrees of freedom.
Copyright © 2024 Rogue Wave Software, Inc., a Perforce company. All Rights Reserved. |