RWLeastSqSVDCalc RWRegressionCalc<double,double>
addObsToBaseCalc() addPredToBaseCalc() calc() clone() |
fail() getTolerance() name() parameters() |
removeObsFromBaseCalc() removePredFromBaseCalc() RWLeastSqSVDCalc() setBaseCalc() |
setTolerance() |
#include <rw/analytics/lsqsvd.h> RWLeastSqSVDCalc calc;
Class RWLeastSqSVDCalc implements the calculation of linear regression parameters using singular value decomposition, as described in Section 5.5.1.3, "RWLeastSqSVDCalc" in the Business Analysis Module User's Guide
#include <rw/analytics/lsqsvd.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]"; RWLeastSqSVDCalc svd; svd.calc(predictorMatrix, observationVector); if ( !svd.fail() ) cout << "Model parameters: " << svd.parameters() << endl; else cout << "Parameter calculation failed." << endl; return 0; }
RWLeastSqSVDCalc();
Constructs an empty RWLeastSqSVDCalc object.
RWLeastSqSVDCalc(double tol=0.0);
Constructs an RWLeastSqSVDCalc object with the specified tolerance parameter tol. Singular values whose value is less than tol are discarded.
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);
Calculates the parameters for the regression model. Invoking this method does not affect the state of any existing base calculation.
virtual RWLeastSqSVDCalc* clone() const;
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 bool fail() const;
Returns true if the calculation failed.
virtual RWCString name() const;
Returns the name of the calculation method.
virtual RWMathVec<double> parameters() const;
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 setBaseCalc(). 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.
void setTolerance(double tol); double getTolerance()const;
Sets and gets the tolerance parameter for the SVD decomposition. Singular values whose value is less than tol are discarded.
© 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.