STK++ 1.0
STK::MultidimRegression Class Reference

The MultidimRegression class allows to regress a multidimensional output variable among a multivariate explanation variable. More...

#include <STK_MultidimRegression.h>

Inheritance diagram for STK::MultidimRegression:
Collaboration diagram for STK::MultidimRegression:

List of all members.

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.

Detailed Description

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 & Destructor Documentation

STK::MultidimRegression::MultidimRegression ( Matrix const *  y = 0,
Matrix const *  x = 0 
)

Constructor.

Parameters:
yVariates to predict
xco-variates

Definition at line 48 of file STK_MultidimRegression.cpp.

                                      : IRegression<Matrix, Matrix, Vector>(y, x)
                                      , coefs_()
{ }
STK::MultidimRegression::~MultidimRegression ( ) [virtual]

Destructor.

Definition at line 53 of file STK_MultidimRegression.cpp.

{ }

Member Function Documentation

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_);
}

Here is the call graph for this function:

void STK::MultidimRegression::regression ( Vector const &  weights) [private, virtual]

compute the weighted regression function.

Parameters:
weightsthe 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;
}

Here is the call graph for this function:

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_);
}

Here is the call graph for this function:

virtual Integer STK::MultidimRegression::computeNbParameter ( ) const [inline, private, virtual]

Compute the number of parameter of the regression function.

Returns:
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().

    { return coefs_.sizeHo() * coefs_.sizeVe(); }

Here is the call graph for this function:


Member Data Documentation


The documentation for this class was generated from the following files: