SourcePro® 2024.1 |
SourcePro® API Reference Guide |
Abstract base class that defines the interface for the regression classes. More...
#include <rw/analytics/regress.h>
Public Types | |
enum | InterceptOption { noIntercept , intercept , addIntercept } |
Public Member Functions | |
void | addInterceptParameter () |
void | addObservation (const RWMathVec< T > &, S) |
void | addObservations (const RWGenMat< T > &, const RWMathVec< S > &) |
void | addPredictor (const RWMathVec< T > &) |
void | addPredictors (const RWGenMat< T > &) |
const RWRegressionCalc< T, S > & | calcMethod () const |
bool | fail () const |
bool | hasInterceptParameter () const |
size_t | numObservations () const |
size_t | numParameters () const |
size_t | numPredictors () const |
RWMathVec< S > | observationVector () |
const RWMathVec< S > | observationVector () const |
const RWMathVec< T > | parameters () const |
RWGenMat< T > | predictorMatrix () |
const RWGenMat< T > | predictorMatrix () const |
void | reCalculateParameters () |
const RWGenMat< T > | regressionMatrix () const |
void | removeInterceptParameter () |
void | removeObservations (size_t startingIndex, size_t numToRemove) |
void | removePredictors (size_t startingIndex, size_t numToRemove) |
void | setCalcMethod (const RWRegressionCalc< T, S > &c, bool recalculate=true) |
void | setRegressionData (const RWGenMat< T > &r, const RWMathVec< S > &o, InterceptOption interceptOpt=addIntercept) |
The abstract base class RWRegression defines the interface for the regression classes in Linear Algebra Module. Classes derived from this class include RWLinearRegression and RWLogisticRegression.
The template parameter T
specifies the datatype for elements in the predictor matrix (double
), and the template parameter S
specifies the datatype for elements in the observation vector (double
for linear regression and bool
for logistic regression).
enum RWRegression::InterceptOption |
Used at construction time to indicated the intercept option used for the model.
void RWRegression< T, S >::addInterceptParameter | ( | ) |
Adds an intercept parameter to the model and recalculates the parameters. If the model already has an intercept parameter, this function does nothing.
void RWRegression< T, S >::addObservation | ( | const RWMathVec< T > & | , |
S | ) |
Appends the given row of observed predictor variable values to the predictor data matrix, appends the observation value to the observation vector, then recalculates the model parameters. The input predictor variable values should not contain a leading 1 for the intercept parameter, regardless of whether or not the model has an intercept parameter. The model accounts for a leading 1 that corresponds to the intercept parameter.
void RWRegression< T, S >::addObservations | ( | const RWGenMat< T > & | , |
const RWMathVec< S > & | ) |
Appends the given rows of observed predictor variable values to the predictor data matrix, appends the observation values to the observation vector, then recalculates the model parameters. The input predictor variable values should not contain a leading 1 for the intercept parameter, regardless of whether or not the model has an intercept parameter. The model accounts for any leading 1s that correspond to the intercept parameter.
void RWRegression< T, S >::addPredictor | ( | const RWMathVec< T > & | ) |
Appends the given column of predictor values to the predictor data matrix and recalculates the regression.
void RWRegression< T, S >::addPredictors | ( | const RWGenMat< T > & | ) |
Appends the given columns of predictor values to the predictor data matrix and recalculates the regression.
|
inline |
Returns the calculation method currently in use.
|
inline |
Returns true
if the most recent parameter calculation fails. Returns false
if the calculation is successful.
|
inline |
Returns true
if the model has an intercept parameter, otherwise returns false
.
|
inline |
Returns the length, n
, of the vector input response vector, \(\mathbf{Y}\)
|
inline |
Returns the number of parameters being estimated. If the model contains an intercept parameter, this is the same as the number of predictor variables plus 1.
|
inline |
Returns the number of predictor variables in the model. If the model contains an intercept parameter, this is 1 less than the number of parameters. If the model does not contain an intercept parameter, this is the same as the number of parameters.
|
inline |
Non-const
version of the observationVector() function. May be used to modify \(\mathbf{Y}\)
|
inline |
Returns the current observation vector, \(\mathbf{Y}\)
|
inline |
Returns \(\hat{\boldsymbol{\beta}}\) , the vector of estimated parameter values.
|
inline |
Non-const
version of the predictorMatrix() function. May be used to modify the contents of the predictor data matrix, \(\mathbf{R}\) If the model does not have an intercept parameter, this method is the same as the regressionMatrix() method. If the model does contain an intercept parameter, be aware that the first column of the returned matrix contains the values for the first predictor variable, not the column of 1s associated with the intercept parameter.
|
inline |
Returns the predictor data matrix, \(\mathbf{R}\) as defined in Section 3.2, "Multiple Linear Regression," in the Business Analysis Module User's Guide. If the model does not have an intercept parameter, this method is the same as the regressionMatrix() method. If the model does contain an intercept parameter, be aware that the first column of the returned matrix contains the values for the first predictor variable, not the column of 1s associated with the intercept parameter.
void RWRegression< T, S >::reCalculateParameters | ( | ) |
Recalculates the regression parameters. Should be called only if you modify the regression data through the methods observationVector() or predictorMatrix().
|
inline |
Returns regression matrix \(\mathbf{X}\) as defined in Section 3.2, "Multiple Linear Regression," in the Business Analysis Module User's Guide. Note that if the model does not contain an intercept parameter, this method returns the same matrix as the predictorMatrix() method.
void RWRegression< T, S >::removeInterceptParameter | ( | ) |
Removes the intercept parameter from the model and recalculates the parameters. If the model currently has no intercept parameter, this function does nothing.
void RWRegression< T, S >::removeObservations | ( | size_t | startingIndex, |
size_t | numToRemove ) |
Removes numToRemove rows from the predictor data matrix beginning with row startingIndex, removes the corresponding elements from the observation vector, then recalculates the regression. The first row has index 0.
void RWRegression< T, S >::removePredictors | ( | size_t | startingIndex, |
size_t | numToRemove ) |
Removes numToRemove columns from the predictor data matrix beginning with column startingIndex, then recalculates the regression. The first column has an index of 0. Note that an index of 0 refers to the first predictor variable and not to the intercept parameter, if the model contains one.
void RWRegression< T, S >::setCalcMethod | ( | const RWRegressionCalc< T, S > & | c, |
bool | recalculate = true ) |
Sets the regression calculation object that is used for computing model parameters to c. Recalculates the model parameters if recalculate is true
.
|
inline |
Sets the predictor matrix, observation vector, and intercept option to the specified values.
Copyright © 2024 Rogue Wave Software, Inc., a Perforce company. All Rights Reserved. |