SourcePro® API Reference Guide

 
List of all members | Public Member Functions

Implements the calculation of linear regression parameters using singular value decomposition. More...

#include <rw/analytics/lsqsvd.h>

Inheritance diagram for RWLeastSqSVDCalc:
RWRegressionCalc< double, double >

Public Member Functions

 RWLeastSqSVDCalc ()
 
 RWLeastSqSVDCalc (double tol)
 
virtual void calc (const RWGenMat< double > &, const RWMathVec< double > &)
 
virtual RWRegressionCalc< double, double > * clone () const
 
virtual bool fail () const
 
double getTolerance () const
 
virtual RWCString name () const
 
virtual RWMathVec< double > parameters () const
 
void setTolerance (double tol)
 
- Public Member Functions inherited from RWRegressionCalc< double, double >
 RWRegressionCalc ()
 
virtual void addObsToBaseCalc (const RWAddObservations< double, double > &dataChange)
 
virtual void addPredToBaseCalc (const RWAddPredictors< double, double > &dataChange)
 
virtual void removeObsFromBaseCalc (const RWRemoveObservations< double, double > &dataChange)
 
virtual void removePredFromBaseCalc (const RWRemovePredictors< double, double > &dataChange)
 
virtual void setBaseCalc (const RWGenMat< double > &r, const RWMathVec< double > &o)
 

Detailed Description

Class RWLeastSqSVDCalc implements the calculation of linear regression parameters using singular value decomposition, as described in Section 5.5.1.3, "RWLeastSqSVDCalc" in the Business Analysis Module User's Guide.

Synopsis
#include <rw/analytics/lsqsvd.h>
Example
#include <rw/analytics/lsqsvd.h>
#include <rw/rstream.h> // Handles proper inclusion of iostream
int main() {
RWGenMat<double> predictorMatrix =
"5x2 [1.2 2.1 8 7 3 3.2 6.4 4.6 2 2.3]";
RWMathVec<double> observationVector = "[2.5 3.7 1.4 2.3 5.6]";
svd.calc(predictorMatrix, observationVector);
if ( !svd.fail() )
cout << "Model parameters: " << svd.parameters() << endl;
else
cout << "Parameter calculation failed." << endl;
return 0;
}

Constructor & Destructor Documentation

RWLeastSqSVDCalc::RWLeastSqSVDCalc ( )

Constructs an RWLeastSqSVDCalc object with a tolerance of 0.0 Singular values whose value is less than tol are discarded.

RWLeastSqSVDCalc::RWLeastSqSVDCalc ( double  tol)

Constructs an RWLeastSqSVDCalc object with the specified tolerance parameter tol. Singular values whose value is less than tol are discarded.

Member Function Documentation

virtual void RWLeastSqSVDCalc::calc ( const RWGenMat< double > &  ,
const RWMathVec< double > &   
)
virtual

Calculates the parameters for the regression model. Invoking this method does not affect the state of any existing base calculation.

Implements RWRegressionCalc< double, double >.

virtual RWRegressionCalc<double, double>* RWLeastSqSVDCalc::clone ( ) const
inlinevirtual

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.

Implements RWRegressionCalc< double, double >.

virtual bool RWLeastSqSVDCalc::fail ( ) const
inlinevirtual

Returns true if the calculation failed.

Implements RWRegressionCalc< double, double >.

double RWLeastSqSVDCalc::getTolerance ( ) const
inline

Gets the tolerance parameter for the SVD decomposition.

virtual RWCString RWLeastSqSVDCalc::name ( ) const
inlinevirtual

Returns the name of the calculation method.

Implements RWRegressionCalc< double, double >.

virtual RWMathVec<double> RWLeastSqSVDCalc::parameters ( ) const
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.

Implements RWRegressionCalc< double, double >.

void RWLeastSqSVDCalc::setTolerance ( double  tol)
inline

Sets the tolerance parameter for the SVD decomposition. Singular values whose value is less than tol are discarded.

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