Abstract base class that defines the interface for the regression classes.
More...
#include <rw/analytics/regress.h>
template<class T, class S>
class RWRegression< T, S >
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).
- Note
- See the Reference Guide entries for RWLinearRegression and RWLogisticRegression for information about the interface.
template<class T, class S>
Used at construction time to indicated the intercept option used for the model.
Enumerator |
---|
noIntercept |
no intercept.
|
intercept |
an intercept with an input matrix that contains a column of 1s prepended to the predictor data matrix.
|
addIntercept |
an intercept that does not contain a column of 1s prepended to the predictor matrix.
|
template<class T, class S>
Adds an intercept parameter to the model and recalculates the parameters. If the model already has an intercept parameter, this function does nothing.
template<class T, class 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.
template<class T, class 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.
template<class T, class S>
Appends the given column of predictor values to the predictor data matrix and recalculates the regression.
template<class T, class S>
Appends the given columns of predictor values to the predictor data matrix and recalculates the regression.
template<class T, class S>
Returns the calculation method currently in use.
template<class T, class S>
Returns true
if the most recent parameter calculation fails. Returns false
if the calculation is successful.
template<class T, class S>
Returns true
if the model has an intercept parameter, otherwise returns false
.
template<class T, class S>
Returns the length, n
, of the vector input response vector, \(\mathbf{Y}\)
template<class T, class S>
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.
template<class T, class S>
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.
template<class T, class S>
Returns the current observation vector, \(\mathbf{Y}\)
template<class T, class S>
template<class T, class S>
Returns \(\hat{\boldsymbol{\beta}}\) , the vector of estimated parameter values.
template<class T, class S>
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.
template<class T, class S>
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.
template<class T, class S>
template<class T, class S>
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.
template<class T, class S>
Removes the intercept parameter from the model and recalculates the parameters. If the model currently has no intercept parameter, this function does nothing.
template<class T, class S>
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.
template<class T, class S>
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.
template<class T, class S>
Sets the regression calculation object that is used for computing model parameters to c. Recalculates the model parameters if recalculate is true
.
template<class T, class S>
Sets the predictor matrix, observation vector, and intercept option to the specified values.