STK++ 1.0

STK::IRegress< YContainer, Matrix > Class Template Reference

Partial specialization of the base class IRegress for the Multidimensional case. More...

#include <STK_IRegressMultivariate.h>

List of all members.

Public Types

typedef IContainerBase
< YContainer
YContainer

Public Member Functions

 IRegress (YContainer const *y=0, Matrix const *x=0)
 Constructor.
virtual ~IRegress ()
 Destructor.
void run ()
 run the computations.
void run (Vector const *p_weights)
 run the weighted computations.
void deleteCol (Integer const &pos)
 delete a column of the p_x_ container
void insertCol (Integer const &pos, Vector const &v)
 insert a column of the p_x_ container
YContainerp_predicted () const
 get the pointer of the container of the predicted values.
YContainerp_residuals () const
 get the pointer of the container of the residuals.
void setData (YContainer const *y, Matrix const *x)
 Set the data set the regression method should use.
void clean ()
 delete allocated memory.

Protected Member Functions

void computeResiduals ()
 Compute the residuals of the model.

Protected Attributes

YContainer const * y_
 Container of the output to regress.
Matrix const * x_
 Container of the regressors.
Vector const * p_weights_
 weigths of the samples.
YContainerp_predicted_
 Container of the predicted output.
YContainerp_residuals_
 Container of the residuals.

Private Member Functions

virtual void regression ()=0
 compute the regression function.
virtual void wregression ()=0
 compute the weighted regression function.
virtual void prediction ()=0
 Compute the predicted outputs by the regression function.

Private Attributes

Qr decomposition
 QR decomposition of the matrix x.

Detailed Description

template<class YContainer>
class STK::IRegress< YContainer, Matrix >

Partial specialization of the base class IRegress for the Multidimensional case.

Definition at line 52 of file STK_IRegressMultivariate.h.


Member Typedef Documentation

template<class YContainer >
typedef IContainerBase<YContainer> STK::IRegress< YContainer, Matrix >::YContainer

Definition at line 55 of file STK_IRegressMultivariate.h.


Constructor & Destructor Documentation

template<class YContainer >
STK::IRegress< YContainer, Matrix >::IRegress ( YContainer const *  y = 0,
Matrix const *  x = 0 
) [inline]

Constructor.

Initialize the data members.

Parameters:
ycontainer with the observed output
xcontainer with the predictors of the model

Definition at line 74 of file STK_IRegressMultivariate.h.

            : y_(y)
            , x_(x)
            , p_weights_(0)
            , p_predicted_(0)
            , p_residuals_(0)
            , decomposition(*x)
    { ;}
template<class YContainer >
virtual STK::IRegress< YContainer, Matrix >::~IRegress ( ) [inline, virtual]

Destructor.

Definition at line 84 of file STK_IRegressMultivariate.h.

    { clean();}

Member Function Documentation

template<class YContainer >
void STK::IRegress< YContainer, Matrix >::run ( ) [inline]

run the computations.

Definition at line 88 of file STK_IRegressMultivariate.h.

References STK::IRegress< YContainer, XContainer >::prediction(), and STK::IRegress< YContainer, XContainer >::regression().

    {
      // remove any existing storage
      clean();
      // compute regression
      regression();
      // predictions
      prediction();
      // compute residuals
      computeResiduals();
    }
template<class YContainer >
void STK::IRegress< YContainer, Matrix >::run ( Vector const *  p_weights) [inline]

run the weighted computations.

Parameters:
p_weightspointer on the weights of the samples

Definition at line 103 of file STK_IRegressMultivariate.h.

References STK::IRegress< YContainer, XContainer >::p_weights_, STK::IRegress< YContainer, XContainer >::prediction(), and STK::IRegress< YContainer, XContainer >::wregression().

    {
      // set weights
      p_weights_ = p_weights;
      // remove any existing storage
      clean();
      // compute weighted regression
      wregression();
      // create container of the predicted value and compute predictions
      prediction();
      // create container of the residuals and compute them
      computeResiduals();
    }
template<class YContainer >
void STK::IRegress< YContainer, Matrix >::deleteCol ( Integer const &  pos)

delete a column of the p_x_ container

template<class YContainer >
void STK::IRegress< YContainer, Matrix >::insertCol ( Integer const &  pos,
Vector const &  v 
)

insert a column of the p_x_ container

template<class YContainer >
YContainer* STK::IRegress< YContainer, Matrix >::p_predicted ( ) const [inline]

get the pointer of the container of the predicted values.

The container p_predicted_ will not be deleted by this.

Returns:
the pointer on the predicted values

Definition at line 126 of file STK_IRegressMultivariate.h.

References STK::IRegress< YContainer, XContainer >::p_predicted_.

{ return p_predicted_;}
template<class YContainer >
YContainer* STK::IRegress< YContainer, Matrix >::p_residuals ( ) const [inline]

get the pointer of the container of the residuals.

The container p_residuals_ will not be deleted by this.

Returns:
the pointer on the residuals

Definition at line 131 of file STK_IRegressMultivariate.h.

References STK::IRegress< YContainer, XContainer >::p_residuals_.

{ return p_residuals_;}
template<class YContainer >
void STK::IRegress< YContainer, Matrix >::setData ( YContainer const *  y,
Matrix const *  x 
) [inline]

Set the data set the regression method should use.

Parameters:
ydata set to adjust
xdata set of the predictors

Definition at line 137 of file STK_IRegressMultivariate.h.

    { y_ = y; x_ = x; decomposition.run(*x);}
template<class YContainer >
void STK::IRegress< YContainer, Matrix >::clean ( ) [inline]
template<class YContainer >
void STK::IRegress< YContainer, Matrix >::computeResiduals ( ) [inline, protected]

Compute the residuals of the model.

The residuals of the model are computed by computing the difference between the observed outputs and the predicted outputs of the model.

Definition at line 153 of file STK_IRegressMultivariate.h.

References STK::IRecursiveTemplate< Leaf >::asLeaf(), STK::IRecursiveTemplate< Leaf >::clone(), STK::IRegress< YContainer, XContainer >::p_predicted_, and STK::IRegress< YContainer, XContainer >::p_residuals_.

    {
      if (p_residuals_) delete p_residuals_;
       p_residuals_ = y_->clone();
      *p_residuals_ = y_->asLeaf() - *p_predicted_;
    }
template<class YContainer >
virtual void STK::IRegress< YContainer, Matrix >::regression ( ) [private, pure virtual]

compute the regression function.

template<class YContainer >
virtual void STK::IRegress< YContainer, Matrix >::wregression ( ) [private, pure virtual]

compute the weighted regression function.

template<class YContainer >
virtual void STK::IRegress< YContainer, Matrix >::prediction ( ) [private, pure virtual]

Compute the predicted outputs by the regression function.


Member Data Documentation

template<class YContainer >
YContainer const* STK::IRegress< YContainer, Matrix >::y_ [protected]

Container of the output to regress.

Definition at line 59 of file STK_IRegressMultivariate.h.

template<class YContainer >
Matrix const* STK::IRegress< YContainer, Matrix >::x_ [protected]

Container of the regressors.

Definition at line 61 of file STK_IRegressMultivariate.h.

template<class YContainer >
Vector const* STK::IRegress< YContainer, Matrix >::p_weights_ [protected]

weigths of the samples.

Definition at line 63 of file STK_IRegressMultivariate.h.

template<class YContainer >
YContainer* STK::IRegress< YContainer, Matrix >::p_predicted_ [protected]

Container of the predicted output.

Definition at line 65 of file STK_IRegressMultivariate.h.

template<class YContainer >
YContainer* STK::IRegress< YContainer, Matrix >::p_residuals_ [protected]

Container of the residuals.

Definition at line 67 of file STK_IRegressMultivariate.h.

template<class YContainer >
Qr STK::IRegress< YContainer, Matrix >::decomposition [private]

QR decomposition of the matrix x.

Definition at line 168 of file STK_IRegressMultivariate.h.


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