SourcePro® API Reference Guide

 
List of all members | Public Member Functions
RWRemoveObservations< T, S > Class Template Reference

Holds information about removing observations from a parameter calculation. More...

#include <rw/analytics/regcalc.h>

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

Public Member Functions

 RWRemoveObservations ()
 
 RWRemoveObservations (const RWRemoveObservations< T, S > &r)
 
 RWRemoveObservations (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)
 
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 RWRemoveObservations< T, S >

RWRemoveObservations holds information regarding the removal of observations from a parameter calculation object's base calculation. This information must consist of the following:

Synopsis
#include <rw/analytics/regcalc.h>
Example
#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. Contains the first five
// rows of regMat.
RWGenMat<double> reducedRegMat( regMat(RWSlice(0,5),RWAll) );
// Full model observation vector.
RWMathVec<double> observationVec( "[12.3 15.6 22.3
44.1 32.5 65.2]" );
// Reduced model observation vector. Contains the first 5
// elements of the full model observation vector.
reducedObservationVec( observationVec(RWSlice(0,5)) );
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 observation contained in the last row of the
// full model regression matrix using the data change class
// RWRemoveObservations. The row to remove is indicated as
// "beginning at index 2, remove 1 row."
RWRemoveObservations<double,double> dataChange( reducedRegMat,
reducedObservationVec, 2, 1 );
calcObject.removeObsFromBaseCalc( 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>
RWRemoveObservations< T, S >::RWRemoveObservations ( )
inline

Default constructor. Constructs an empty RWRemoveObservations object.

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

Copy constructor. Constructs a copy of r.

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

Constructs an RWRemoveObservations 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 numToRemove rows beginning with index startIndex, and that the observation vector o is obtained from the base calculation by deleting numToRemove values beginning with index startIndex. If setBaseToLast is true, the base calculations regression matrix is set to r.

Member Function Documentation

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

Returns the number of observations removed.

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

Sets the number of observations to remove.

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

Sets the starting index.

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

Returns the starting index.

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