>
Member Functions | |||
addObsToBaseCalc() addPredToBaseCalc() calc() |
clone() fail() name() |
parameters() removeObsFromBaseCalc() removePredFromBaseCalc() |
setBaseCalc() |
#include <rw/analytics/regcalc.h>
Abstract base class
>The abstract base class RWRegressionCalc<T,S> defines the interface for the regression parameter calculation objects used in Analytics.h++. Classes derived from RWRegressionCalc<T,S> include RWLeastSqQRCalc, RWLeastSqQRPvtCalc, and RWLeastSqSVDCalc for linear regression, and RWLogisticIterLSQ and RWLogisticLevenbergMarquardt for logistic regression. The template parameter T specifies the datatype for elements in the predictor matrix (usually double), and the template parameter S specifies the datatype for elements in the observation vector (usually double for linear regression and RWBoolean for logistic regression).
If you want to provide your own parameter calculation algorithm as an alternative to those already available in Analytics.h++, it is useful to understand the interface to RWRegressionCalc<T,S>. Otherwise, once you have provided an implementation class derived from RWRegressionCalc<T,S>, you can use that implementation simply by calling the method RWLinearRegression::setCalcMethod() or the method RWLogisticRegression::setCalcMethod() with an instance of the implementation class.
>RWRegressionCalc();
Constructs an empty RWRegressionCalc object.
virtual void addObsToBaseCalc(const RWAddObservations<T,S>& 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<T,S>& r);
Expands the regression model to include new predictor variables. This method has 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<T>& xdata, RWMathVec<S> 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 RWRegressionCalc<T,S>* 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<T> 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<T,S>& 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<T,S>& 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<T>& xdata, const RWMathVec<S>& 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.