rwlogo
SourcePro C++ 12.0

SourcePro® C++ API Reference Guide



   SourcePro C++
Documentation Home

RWRegressionCalc< T, S > Class Template Reference
[Parameter Calculation]

Defines the interface for regression parameter calculation objects. More...

#include <rw/analytics/regcalc.h>

List of all members.

Public Member Functions

 RWRegressionCalc ()
virtual void calc (const RWGenMat< T > &r, const RWMathVec< S > &o)=0
virtual void setBaseCalc (const RWGenMat< T > &r, const RWMathVec< S > &o)
virtual void addPredToBaseCalc (const RWAddPredictors< T, S > &dataChange)
virtual void removePredFromBaseCalc (const RWRemovePredictors< T, S > &dataChange)
virtual void addObsToBaseCalc (const RWAddObservations< T, S > &dataChange)
virtual void removeObsFromBaseCalc (const RWRemoveObservations< T, S > &dataChange)
virtual bool fail () const =0
virtual RWMathVec< T > parameters () const =0
virtual RWCString name () const =0
virtual RWRegressionCalc< T, S > * clone () const =0

Detailed Description

template<class T, class S>
class RWRegressionCalc< T, S >

The abstract base class RWRegressionCalc<T,S> defines the interface for the regression parameter calculation objects used in Linear Algebra Module. 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 bool for logistic regression).

If you want to provide your own parameter calculation algorithm as an alternative to those already available in Linear Algebra Module, 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.

Synopsis

 #include <rw/analytics/regcalc.h>

Constructor & Destructor Documentation

template<class T, class S>
RWRegressionCalc< T, S >::RWRegressionCalc (  )  [inline]

Constructs an empty RWRegressionCalc object.


Member Function Documentation

template<class T, class S>
virtual void RWRegressionCalc< T, S >::addObsToBaseCalc ( const RWAddObservations< T, S > &  dataChange  )  [virtual]

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.

Reimplemented in RWLogisticLevenbergMarquardt, and RWLogisticIterLSQ.

template<class T, class S>
virtual void RWRegressionCalc< T, S >::addPredToBaseCalc ( const RWAddPredictors< T, S > &  dataChange  )  [virtual]

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.

Reimplemented in RWLogisticLevenbergMarquardt, RWLogisticIterLSQ, and RWLeastSqQRCalc.

template<class T, class S>
virtual void RWRegressionCalc< T, S >::calc ( const RWGenMat< T > &  r,
const RWMathVec< S > &  o 
) [pure virtual]

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.

Implemented in RWLogisticLevenbergMarquardt, RWLogisticIterLSQ, RWLeastSqQRCalc, RWLeastSqQRPvtCalc, and RWLeastSqSVDCalc.

template<class T, class S>
virtual RWRegressionCalc<T,S>* RWRegressionCalc< T, S >::clone (  )  const [pure virtual]

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.

Implemented in RWLogisticLevenbergMarquardt, RWLogisticIterLSQ, RWLeastSqQRCalc, RWLeastSqQRPvtCalc, and RWLeastSqSVDCalc.

template<class T, class S>
virtual bool RWRegressionCalc< T, S >::fail (  )  const [pure virtual]

Returns true if the calculation failed.

Implemented in RWLogisticLevenbergMarquardt, RWLogisticIterLSQ, RWLeastSqQRCalc, RWLeastSqQRPvtCalc, and RWLeastSqSVDCalc.

template<class T, class S>
virtual RWCString RWRegressionCalc< T, S >::name (  )  const [pure virtual]

Returns the name of the calculation method.

Implemented in RWLogisticLevenbergMarquardt, RWLogisticIterLSQ, RWLeastSqQRCalc, RWLeastSqQRPvtCalc, and RWLeastSqSVDCalc.

template<class T, class S>
virtual RWMathVec<T> RWRegressionCalc< T, S >::parameters (  )  const [pure virtual]

Returns the parameters from the last calculation performed. If the calculation failed, and this method is called, an exception of type RWInternalErr is thrown.

Implemented in RWLogisticLevenbergMarquardt, RWLogisticIterLSQ, RWLeastSqQRCalc, RWLeastSqQRPvtCalc, and RWLeastSqSVDCalc.

template<class T, class S>
virtual void RWRegressionCalc< T, S >::removeObsFromBaseCalc ( const RWRemoveObservations< T, S > &  dataChange  )  [virtual]

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.

Reimplemented in RWLogisticLevenbergMarquardt, and RWLogisticIterLSQ.

template<class T, class S>
virtual void RWRegressionCalc< T, S >::removePredFromBaseCalc ( const RWRemovePredictors< T, S > &  dataChange  )  [virtual]

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.

Reimplemented in RWLogisticLevenbergMarquardt, RWLogisticIterLSQ, and RWLeastSqQRCalc.

template<class T, class S>
virtual void RWRegressionCalc< T, S >::setBaseCalc ( const RWGenMat< T > &  r,
const RWMathVec< S > &  o 
) [inline, virtual]

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.

Reimplemented in RWLogisticLevenbergMarquardt, RWLogisticIterLSQ, and RWLeastSqQRCalc.

 All Classes Functions Variables Typedefs Enumerations Enumerator Friends

© 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.