>
Member Functions | |||
baseToLast() newObservationVec() newRegressionMat() |
numRemoved() setBaseToLast() setNewObservationVec() |
setNewRegressionMat() setNumRemoved() setStartIndex() |
startIndex() |
>#include <rw/analytics/regcalc.h> RWRemovePredictors<double,double> a;
Class RWRemovePredictors<T,S> contains information regarding the removal of predictor variables from a base parameter calculation object's base calculation. The removal information must consist of the following:
The new regression matrix. This is the regression matrix used in the parameter calculation object's base calculation with the predictors removed.
The new observation vector. This is assumed to be the same as the observation vector used in the parameter calculation object's base calculation.
The predictors removed in the form of a starting index and number to remove.
#include <rw/analytics/lsqqr.h> #include <rw/rstream.h> int main() { // Full model regression matrix. RWGenMat<double> regMat( "6x3 [1 1.3 .54 \ 1 3.5 .65 \ 1 -2.3 .88 \ 1 8.2 .76 \ 1 -4.2 .32 \ 1 2.4 .43]" ); // Reduced model regression matrix. Constains the first two // columns of regMat. RWGenMat<double> reducedRegMat( regMat(RWAll,RWSlice(0,2)) ); RWMathVec<double> observationVec( "[12.3 15.6 22.3 44.1 32.5 65.2]" ); RWLeastSqQRCalc calcObject; // Set the base calculation for the parameter calculation // object to the full regression matrix. calcObject.setBaseCalc( regMat, observationVec ); if ( calcObject.fail() ) { cout << "Parameter calculation for full model failed" << endl; return 1; } cout << "Parameters for full model:" << calcObject.parameters() << endl; // Remove the predictor data contained in the last column of // the full model regression matrix using the data change // class RWRemovePredictors. The column to be removed is // indicated as "beginning at index 2, remove 1 column." RWRemovePredictors<double,double> dataChange( reducedRegMat, observationVec, 2, 1 ); calcObject.removePredFromBaseCalc( dataChange ); if ( calcObject.fail() ) { cout << "Parameter calculation for reduced model failed" << endl; return 1; } cout << "Parameters for reduced model:" << calcObject.parameters() << endl; return 0; }>
RWRemovePredictors();
Default constructor. Constructs an empty RWRemovePredictors object.
RWRemovePredictors(const RWRemovePredictors<T,S>& r);
Copy constructor. Constructs a copy of r.
RWRemovePredictors(const RWGenMat<T>& r, const RWMathVec<S> o, size_t startIndex, size_t numRemoved, RWBoolean setBaseToLast = FALSE);
Constructs an RWRemovePredictors object with the given regression matrix and observation vector. It assumes that the matrix r is obtained from the base calculations regression matrix by deleting numRemoved columns beginning with index startIndex, and that the observation vector o is identical to the base calculations. If setBaseToLast is TRUE, the base calculations regression matrix is set to r.
RWBoolean baseToLast();
Returns TRUE if the base calculation is set to the new regression matrix and new observation vector.
const RWMathVec<S>& newObservationVec() const;
Returns the new observation vector.
const RWGenMat<T>& newRegressionMat() const;
Returns the new regression matrix.
size_t numRemoved() const;
Returns the number of predictors removed.
void setBaseToLast(RWBoolean s);
Sets the base to last option to s.
void setNewObservationVec(const RWMathVec<S>& o);
Sets the new observation to o.
void setNewRegressionMat(const RWGenMat<T>& r);
Sets the new regression matrix to r.
void setNumRemoved(size_t nr);
Sets the number of predictors to be removed.
void setStartIndex(size_t i);
Sets the starting index.
size_t startIndex() const;
Returns the starting index.
©Copyright 1999, Rogue Wave Software, Inc.
Send mail to report errors or comment on the documentation.