rwlogo
SourcePro C++ 12.0

SourcePro® C++ API Reference Guide



   SourcePro C++
Documentation Home

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

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 >

List of all members.

Public Member Functions

 RWRemovePredictors ()
 RWRemovePredictors (const RWRemovePredictors< T, S > &r)
 RWRemovePredictors (const RWGenMat< T > &r, const RWMathVec< S > o, size_t startIndex, size_t numRemoved, bool setBaseToLast=false)
size_t numRemoved () const
void setNumRemoved (size_t nr)
size_t startIndex () const
void setStartIndex (size_t i)

Detailed Description

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

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:

Synopsis

 #include <rw/analytics/regcalc.h>
 RWRemovePredictors<double,double> a;

Examples

 #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;
 }

Constructor & Destructor Documentation

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

Default constructor. Constructs an empty RWRemovePredictors object.

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

Copy constructor. Constructs a copy of r.

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

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

Returns the number of predictors removed.

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

Sets the number of predictors to be removed.

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

Sets the starting index.

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

Returns the starting index.

 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.