>
RWLeastSqQRCalc RWRegressionCalc<double,double>
Member Functions | |||
addObsToBaseCalc() addPredToBaseCalc() calc() |
clone() fail() name() |
parameters() removeObsFromBaseCalc() removePredFromBaseCalc() |
setBaseCalc() |
>#include <rw/analytics/lsqqr.h> RWLeastSqQRCalc calc;
Class RWLeastSqQRCalc implements the calculation of linear regression parameters using QR decomposition, as described in Section 5.5.1.1.
>#include <rw/analytics/lsqqr.h> #include <rw/rstream.h> // Handles proper 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]"; RWLeastSqQRCalc qr; qr.calc(predictorMatrix, observationVector); if ( !qr.fail() ) cout << "Model parameters: " << qr.parameters() << endl; else cout << "Parameter calculation failed." << endl; return 0; }>
RWLeastSqQRCalc();
Constructs an empty RWLeastSqQRCalc object.
virtual void addObsToBaseCalc(const RWAddObservations<double,double>& r);
Recalculates the regression model using an additional set of predictor-observation data pairs. This method offers the option of using results from the base calculation to calculate the coefficients for the larger data set. Consequently, this method can be called only when a base calculation has been set using setBaseCalc(). The input variable provides the additional data. The default implementation simply recalculates the parameters from scratch using the calc() method.
virtual void addPredToBaseCalc(const RWAddPredictors<double,double>& r);
Expands the regression model to include new predictor variables. This method offers the option of using results from the base calculation to calculate the coefficients for the larger predictor set. Consequently, this method can be called only when a base calculation has been set using setBaseCalc(). The input variable contains the data for the added predictor variables. The default implementation simply recalculates the parameters from scratch using the calc() method.
virtual void calc(const RWGenMat<double>& xdata, RWMathVec<double> ydata)=0;
Calculates the parameters for the regression model. This is a pure virtual function that must be overridden by deriving classes. Invoking this method does not affect the state of any existing base calculation.
virtual RWLeastSqQRCalc<double,double>* clone() const = 0;
Allocates and creates a clone, or exact copy, of the current instance, and returns a pointer to the copy. Caller is responsible for deleting the returned object.
virtual RWBoolean fail() const = 0;
Returns TRUE if the calculation failed.
virtual RWCString name() const = 0;
Returns the name of the calculation method.
virtual RWMathVec<double> parameters() const = 0;
Returns the parameters from the last calculation performed. If the calculation failed and this method is called, an exception of type RWInternalErr is thrown.
virtual void removeObsFromBaseCalc(const
RWRemoveObservations<double,double>& r);
Modifies the regression model by removing a set of contiguous predictor-observation data pairs, and recalculating the parameters. This method offers the option of using results from the base calculation to calculate the coefficients for the smaller data set. Consequently, this method can be called only when a base calculation has been set using setBaseCalc(). The input variable indicates the indices of the rows to be removed from the regression matrix and from the observation vector used in the base calculation. The default implementation simply recalculates the parameters from scratch using the calc() method.
virtual void removePredFromBaseCalc(const RWRemovePredictors<double,double>& r);
Shrinks the regression model to exclude previously used predictor variables. This method offers the option of using results from the base calculation to calculate the coefficients for the smaller predictor set. Consequently, this method can be called only when a base calculation has been set using statistical(). The input variable indicates the indices of the columns to be removed from the regression matrix used in the base calculation. The default implementation simply recalculates the parameters from scratch using the calc() method.
virtual void setBaseCalc(const RWGenMat<double>& xdata, const RWMathVec<double>& ydata);
Calculates the coefficients for the input regression data and sets the base calculation to this calculation. Deriving classes need not override this method if they do not store base calculation results. The default implementation calls the calc() method.
©Copyright 1999, Rogue Wave Software, Inc.
Send mail to report errors or comment on the documentation.