rwlogo
SourcePro C++ 12.0

SourcePro® C++ API Reference Guide



   SourcePro C++
Documentation Home

RWLeastSqQRCalc Class Reference
[Parameter Calculation]

Calculates linear regression parameters using QR decomposition. More...

#include <rw/analytics/lsqqr.h>

Inheritance diagram for RWLeastSqQRCalc:
RWRegressionCalc< double, double >

List of all members.

Public Member Functions

 RWLeastSqQRCalc ()
virtual void calc (const RWGenMat< double > &r, const RWMathVec< double > &o)
virtual RWRegressionCalc
< double, double > * 
clone () const
virtual bool fail () const
virtual RWCString name () const
virtual void setBaseCalc (const RWGenMat< double > &, const RWMathVec< double > &)
virtual void addPredToBaseCalc (const RWAddPredictors< double, double > &dataChange)
virtual void removePredFromBaseCalc (const RWRemovePredictors< double, double > &dataChange)
virtual RWMathVec< double > parameters () const

Detailed Description

Class RWLeastSqQRCalc implements the calculation of linear regression parameters using QR decomposition, as described in Section 5.5.1.1, "RWLeastSqQRCalc," in the Business Analysis Module User's Guide.

Synopsis

 #include <rw/analytics/lsqqr.h>

 RWLeastSqQRCalc calc;

Examples

 #include <rw/analytics/lsqqr.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]";
  RWLeastSqQRCalc qr;

  qr.calc(predictorMatrix, observationVector);

  if ( !qr.fail() )
   cout << "Model parameters: " << qr.parameters() << endl;
  else
   cout << "Parameter calculation failed." << endl;
  return 0;
 }

Constructor & Destructor Documentation

RWLeastSqQRCalc::RWLeastSqQRCalc (  ) 

Constructs an empty RWLeastSqQRCalc object.


Member Function Documentation

virtual void RWLeastSqQRCalc::addPredToBaseCalc ( const RWAddPredictors< double, double > &  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 from RWRegressionCalc< double, double >.

virtual void RWLeastSqQRCalc::calc ( const RWGenMat< double > &  r,
const RWMathVec< double > &  o 
) [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>* RWLeastSqQRCalc::clone (  )  const [inline, 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.

Implements RWRegressionCalc< double, double >.

virtual bool RWLeastSqQRCalc::fail (  )  const [inline, virtual]

Returns true if the calculation failed.

Implements RWRegressionCalc< double, double >.

virtual RWCString RWLeastSqQRCalc::name (  )  const [inline, virtual]

Returns the name of the calculation method.

Implements RWRegressionCalc< double, double >.

virtual RWMathVec<double> RWLeastSqQRCalc::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 >.

virtual void RWLeastSqQRCalc::removePredFromBaseCalc ( const RWRemovePredictors< double, double > &  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 from RWRegressionCalc< double, double >.

virtual void RWLeastSqQRCalc::setBaseCalc ( const RWGenMat< double > &  r,
const RWMathVec< double > &  o 
) [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 from RWRegressionCalc< double, double >.

 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.