Implements the calculation of linear regression parameters using singular value decomposition.
More...
#include <rw/analytics/lsqsvd.h>
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>
Implements the calculation of linear regression parameters using singular value decomposition.
Definition lsqsvd.h:69
virtual void calc(const RWGenMat< double > &, const RWMathVec< double > &)
- Example
#include <rw/analytics/lsqsvd.h>
#include <rw/rstream.h>
int main() {
"5x2 [1.2 2.1 8 7 3 3.2 6.4 4.6 2 2.3]";
svd.
calc(predictorMatrix, observationVector);
cout <<
"Model parameters: " << svd.
parameters() << endl;
} else {
cout << "Parameter calculation failed." << endl;
}
return 0;
}
A templatized general matrix class.
Definition genmat.h:735
virtual RWMathVec< double > parameters(void) const
virtual bool fail(void) const
Definition lsqsvd.h:109
A templatized vector class.
Definition mathvec.h:645
◆ RWLeastSqSVDCalc() [1/2]
RWLeastSqSVDCalc::RWLeastSqSVDCalc |
( |
| ) |
|
Constructs an RWLeastSqSVDCalc object with a tolerance of 0.0
Singular values whose value is less than tol are discarded.
◆ RWLeastSqSVDCalc() [2/2]
RWLeastSqSVDCalc::RWLeastSqSVDCalc |
( |
double | tol | ) |
|
|
explicit |
Constructs an RWLeastSqSVDCalc object with the specified tolerance parameter tol. Singular values whose value is less than tol are discarded.
◆ calc()
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 >.
◆ clone()
virtual RWRegressionCalc< double, double > * RWLeastSqSVDCalc::clone |
( |
void | | ) |
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 >.
◆ fail()
virtual bool RWLeastSqSVDCalc::fail |
( |
void | | ) |
const |
|
inlinevirtual |
◆ getTolerance()
double RWLeastSqSVDCalc::getTolerance |
( |
| ) |
const |
|
inline |
Gets the tolerance parameter for the SVD decomposition.
◆ name()
virtual RWCString RWLeastSqSVDCalc::name |
( |
void | | ) |
const |
|
inlinevirtual |
◆ parameters()
virtual RWMathVec< double > RWLeastSqSVDCalc::parameters |
( |
void | | ) |
const |
|
virtual |
◆ setTolerance()
void RWLeastSqSVDCalc::setTolerance |
( |
double | tol | ) |
|
|
inline |
Sets the tolerance parameter for the SVD decomposition. Singular values whose value is less than tol are discarded.