Calculates linear regression parameters using QR decomposition with pivoting.
More...
#include <rw/analytics/lsqqrpvt.h>
Class RWLeastSqQRPvtCalc implements the calculation of linear regression parameters using QR decomposition with pivoting, as described in Section 5.5.1.2, "RWLeastSqQRPvtCalc" in the Business Analysis Module User's Guide.
- Synopsis
#include <rw/analytics/lsqqrpvt.h>
Calculates linear regression parameters using QR decomposition with pivoting.
Definition lsqqrpvt.h:68
virtual void calc(const RWGenMat< double > &, const RWMathVec< double > &)
- Example
#include <rw/analytics/lsqqrpvt.h>
#include <rw/rstream.h>
int main() {
"5x2 [1.2 2.1 8 7 3 3.2 6.4 4.6 2 2.3]";
qrpvt.
calc(predictorMatrix, observationVector);
cout <<
"Model parameters: " << qrpvt.
parameters() << endl;
} else {
cout << "Parameter calculation failed." << endl;
}
return 0;
}
A templatized general matrix class.
Definition genmat.h:735
virtual bool fail(void) const
Definition lsqqrpvt.h:115
virtual RWMathVec< double > parameters(void) const
Definition lsqqrpvt.h:104
A templatized vector class.
Definition mathvec.h:645
◆ RWLeastSqQRPvtCalc() [1/2]
RWLeastSqQRPvtCalc::RWLeastSqQRPvtCalc |
( |
| ) |
|
Constructs an RWLeastSqQRPvtCalc object with a tolerance of 0.0
. Entries along the diagonal of the R factor of the QR decomposition less than this tolerance are treated as zero. Using this can prevent insignificant entries of R from corrupting your solution.
◆ RWLeastSqQRPvtCalc() [2/2]
RWLeastSqQRPvtCalc::RWLeastSqQRPvtCalc |
( |
double | tol | ) |
|
|
explicit |
Constructs an RWLeastSqQRPvtCalc object with the specified tolerance parameter tol. Entries along the diagonal of the R factor of the QR decomposition less than this tolerance are treated as zero. Using this can prevent insignificant entries of R from corrupting your solution.
◆ calc()
virtual void RWLeastSqQRPvtCalc::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 > * RWLeastSqQRPvtCalc::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 RWLeastSqQRPvtCalc::fail |
( |
void | | ) |
const |
|
inlinevirtual |
◆ getTolerance()
double RWLeastSqQRPvtCalc::getTolerance |
( |
| ) |
const |
|
inline |
Gets the tolerance parameter for the QR decomposition. Entries along the diagonal of the R factor of the QR decomposition that are less than this tolerance are treated as zero. Using this can prevent insignificant entries of R from corrupting your solution.
◆ name()
virtual RWCString RWLeastSqQRPvtCalc::name |
( |
void | | ) |
const |
|
inlinevirtual |
◆ parameters()
virtual RWMathVec< double > RWLeastSqQRPvtCalc::parameters |
( |
void | | ) |
const |
|
inlinevirtual |
◆ setTolerance()
void RWLeastSqQRPvtCalc::setTolerance |
( |
double | tol | ) |
|
|
inline |
Sets the tolerance parameter for the QR decomposition. Entries along the diagonal of the R factor of the QR decomposition that are less than this tolerance are treated as zero. Using this can prevent insignificant entries of R from corrupting your solution.