|
STK++ 1.0
|
The MultidimRegression class allows to regress a multidimensional output variable among a multivariate explanation variable.
More...
#include <STK_MultidimRegression.h>


Public Member Functions | |
| MultidimRegression (Matrix const *y=0, Matrix const *x=0) | |
| Constructor. | |
| virtual | ~MultidimRegression () |
| Destructor. | |
Protected Attributes | |
| Matrix | coefs_ |
Private Member Functions | |
| virtual void | regression () |
| compute the regression function. | |
| virtual void | regression (Vector const &weights) |
| compute the weighted regression function. | |
| virtual void | prediction () |
| Compute the predicted outputs by the regression function. | |
| virtual Integer | computeNbParameter () const |
| Compute the number of parameter of the regression function. | |
The MultidimRegression class allows to regress a multidimensional output variable among a multivariate explanation variable.
Definition at line 50 of file STK_MultidimRegression.h.
Constructor.
| y | Variates to predict |
| x | co-variates |
Definition at line 48 of file STK_MultidimRegression.cpp.
: IRegression<Matrix, Matrix, Vector>(y, x)
, coefs_()
{ }
| STK::MultidimRegression::~MultidimRegression | ( | ) | [virtual] |
| void STK::MultidimRegression::regression | ( | ) | [private, virtual] |
compute the regression function.
Implements STK::IRegression< Matrix, Matrix, Vector >.
Definition at line 57 of file STK_MultidimRegression.cpp.
References coefs_, STK::mult(), STK::multLeftTranspose(), STK::IRegression< Matrix, Matrix, Vector >::p_x_, and STK::IRegression< Matrix, Matrix, Vector >::p_y_.
{
// compute X'X
MatrixSquare prod;
multLeftTranspose(p_x_->asLeaf(), prod);
// compute (X'X)^{-1}
GinvSymmetric inv;
inv(prod);
// compute X'Y
Matrix temp;
multLeftTranspose(p_x_->asLeaf(), p_y_->asLeaf(), temp);
// compute (X'X)^{-1}X'Y
mult(prod, temp, coefs_);
}

| void STK::MultidimRegression::regression | ( | Vector const & | weights | ) | [private, virtual] |
compute the weighted regression function.
| weights | the weights of the samples |
Implements STK::IRegression< Matrix, Matrix, Vector >.
Definition at line 76 of file STK_MultidimRegression.cpp.
References coefs_, STK::mult(), STK::IRegression< Matrix, Matrix, Vector >::p_x_, STK::IRegression< Matrix, Matrix, Vector >::p_y_, and STK::weightedMultLeftTranspose().
{
// compute X'WX
MatrixSquare* prod = weightedMultLeftTranspose(p_x_->asLeaf(), weights);
// compute (X'WX)^{-1}
GinvSymmetric inv;
inv(prod);
// compute X'WY
Matrix* temp = weightedMultLeftTranspose(p_x_->asLeaf(), p_y_->asLeaf(), weights);
// compute (X'WX)^{-1}X'WY
mult(*prod, *temp, coefs_);
// remove temporary storages
delete temp;
delete prod;
}

| void STK::MultidimRegression::prediction | ( | ) | [private, virtual] |
Compute the predicted outputs by the regression function.
Implements STK::IRegression< Matrix, Matrix, Vector >.
Definition at line 96 of file STK_MultidimRegression.cpp.
References coefs_, STK::mult(), STK::IRegression< Matrix, Matrix, Vector >::p_predicted_, and STK::IRegression< Matrix, Matrix, Vector >::p_x_.
{
// remove existing predictions if any (should not be the case)
if (!p_predicted_) p_predicted_ = new Matrix;
// compute predictions
mult(p_x_->asLeaf(), coefs_, *p_predicted_);
}

| virtual Integer STK::MultidimRegression::computeNbParameter | ( | ) | const [inline, private, virtual] |
Compute the number of parameter of the regression function.
Implements STK::IRegression< Matrix, Matrix, Vector >.
Definition at line 77 of file STK_MultidimRegression.h.
References coefs_, STK::IContainer2D::sizeHo(), and STK::IContainer2D::sizeVe().

Matrix STK::MultidimRegression::coefs_ [protected] |
Definition at line 63 of file STK_MultidimRegression.h.
Referenced by computeNbParameter(), prediction(), and regression().