SourcePro® API Reference Guide

 
Loading...
Searching...
No Matches
RWRemovePredictors< T, S > Class Template Reference

Holds information about the removal of predictor variables from a parameter calculation. More...

#include <rw/analytics/regcalc.h>

Inheritance diagram for RWRemovePredictors< T, S >:
RWRegressionDataChange< T, S >

Public Member Functions

 RWRemovePredictors ()
 
 RWRemovePredictors (const RWGenMat< T > &r, const RWMathVec< S > o, size_t startIndex, size_t numRemoved, bool setBaseToLast=false)
 
 RWRemovePredictors (const RWRemovePredictors< T, S > &r)
 
size_t numRemoved () const
 
void setNumRemoved (size_t nr)
 
void setStartIndex (size_t i)
 
size_t startIndex () const
 
- Public Member Functions inherited from RWRegressionDataChange< T, S >
bool baseToLast () const
 
const RWMathVec< S > & newObservationVec () const
 
const RWGenMat< T > & newRegressionMat () const
 
void setBaseToLast (bool s)
 
void setNewObservationVec (const RWMathVec< S > &o)
 
void setNewRegressionMat (const RWGenMat< T > &r)
 

Detailed Description

template<class T, class S>
class RWRemovePredictors< T, S >

Class RWRemovePredictors 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.
Synopsis
#include <rw/analytics/regcalc.h>
Holds information about the removal of predictor variables from a parameter calculation.
Definition regcalc.h:332
Example
#include <rw/analytics/lsqqr.h>
#include <rw/rstream.h>
int main() {
// Full model regression matrix.
"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. Contains 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;
}
A templatized general matrix class.
Definition genmat.h:741
Calculates linear regression parameters using QR decomposition.
Definition lsqqr.h:68
virtual void setBaseCalc(const RWGenMat< double > &, const RWMathVec< double > &)
virtual RWMathVec< double > parameters(void) const
virtual bool fail(void) const
Definition lsqqr.h:99
virtual void removePredFromBaseCalc(const RWRemovePredictors< double, double > &dataChange)
A templatized vector class.
Definition mathvec.h:667
Represents an index that can be used for subscripting vectors, matrices, and arrays.
Definition rwslice.h:105

Constructor & Destructor Documentation

◆ RWRemovePredictors() [1/3]

template<class T , class S >
RWRemovePredictors< T, S >::RWRemovePredictors ( )
inline

Default constructor. Constructs an empty RWRemovePredictors object.

◆ RWRemovePredictors() [2/3]

template<class T , class S >
RWRemovePredictors< T, S >::RWRemovePredictors ( const RWRemovePredictors< T, S > & r)
inline

Copy constructor. Constructs a copy of r.

◆ RWRemovePredictors() [3/3]

template<class T , class S >
RWRemovePredictors< T, S >::RWRemovePredictors ( const RWGenMat< T > & r,
const RWMathVec< S > o,
size_t startIndex,
size_t numRemoved,
bool setBaseToLast = false )
inline

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.

Member Function Documentation

◆ numRemoved()

template<class T , class S >
size_t RWRemovePredictors< T, S >::numRemoved ( ) const
inline

Returns the number of predictors removed.

◆ setNumRemoved()

template<class T , class S >
void RWRemovePredictors< T, S >::setNumRemoved ( size_t nr)
inline

Sets the number of predictors to be removed.

◆ setStartIndex()

template<class T , class S >
void RWRemovePredictors< T, S >::setStartIndex ( size_t i)
inline

Sets the starting index.

◆ startIndex()

template<class T , class S >
size_t RWRemovePredictors< T, S >::startIndex ( ) const
inline

Returns the starting index.

Copyright © 2024 Rogue Wave Software, Inc., a Perforce company. All Rights Reserved.