STK++ 1.0

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

Interface base class for Regression methods. More...

#include <STK_IRegress.h>

List of all members.

Public Member Functions

 IRegress (YContainer const *p_y=0, XContainer const *p_x=0)
 Constructor.
virtual ~IRegress ()
 virtual destructor.
void run ()
 run the computations.
void run (Vector const *p_weights)
 run the weighted computations.
YContainer * p_predicted () const
 get the pointer of the container of the predicted values.
YContainer * p_residuals () const
 get the pointer of the container of the residuals.
void setData (YContainer const *p_y, XContainer const *p_x)
 Set the data set the regression method should use.
void setY (YContainer const *p_y)
 Set the Y data set the regression method should use.
void setX (XContainer const *p_x)
 Set the X data set.

Protected Member Functions

virtual void preWork ()
 perform any work needed before the call of the regression method.
void residuals ()
 Compute the residuals of the model.

Protected Attributes

YContainer const * p_y_
 Container of the output to regress.
XContainer const * p_x_
 Container of the regressors.
Vector const * p_weights_
 weigths of the samples.
YContainer * p_predicted_
 Container of the predicted output.
YContainer * p_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 and store the result in the p_predicted_ container.
void clear ()
 delete allocated memory.

Detailed Description

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

Interface base class for Regression methods.

Definition at line 50 of file STK_IRegress.h.


Constructor & Destructor Documentation

template<class YContainer, class XContainer>
STK::IRegress< YContainer, XContainer >::IRegress ( YContainer const *  p_y = 0,
XContainer const *  p_x = 0 
) [inline]

Constructor.

Initialize the data members.

Parameters:
p_ycontainer with the observed output
p_xcontainer with the predictors (inputs) of the model

Definition at line 69 of file STK_IRegress.h.

            : p_y_(p_y)
            , p_x_(p_x)
            , p_weights_(0)
            , p_predicted_(0)
            , p_residuals_(0)
    { ;}
template<class YContainer, class XContainer>
virtual STK::IRegress< YContainer, XContainer >::~IRegress ( ) [inline, virtual]

virtual destructor.

Definition at line 78 of file STK_IRegress.h.

    { clear();}

Member Function Documentation

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

run the computations.

Definition at line 82 of file STK_IRegress.h.

Referenced by STK::IAAModel::regression(), and STK::IAAModel::wregression().

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

run the weighted computations.

Parameters:
p_weightspointer on the weights of the samples

Definition at line 97 of file STK_IRegress.h.

    {
      // set weights
      p_weights_ = p_weights;
      // remove any existing storage
      clear();
      // compute weighted regression
      wregression();
      // create container of the predicted value and compute prediction
      prediction();
      // create container of the residuals and compute them
      residuals();
    }
template<class YContainer, class XContainer>
YContainer* STK::IRegress< YContainer, XContainer >::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 115 of file STK_IRegress.h.

Referenced by STK::IAAModel::regression(), and STK::IAAModel::wregression().

    { return p_predicted_;}
template<class YContainer, class XContainer>
YContainer* STK::IRegress< YContainer, XContainer >::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 121 of file STK_IRegress.h.

Referenced by STK::IAAModel::regression(), and STK::IAAModel::wregression().

    {  return p_residuals_;}
template<class YContainer, class XContainer>
void STK::IRegress< YContainer, XContainer >::setData ( YContainer const *  p_y,
XContainer const *  p_x 
) [inline]

Set the data set the regression method should use.

Parameters:
p_ydata set to adjust
p_xdata set of the predictors

Definition at line 128 of file STK_IRegress.h.

    { p_y_ = p_y; p_x_ = p_x;}
template<class YContainer, class XContainer>
void STK::IRegress< YContainer, XContainer >::setY ( YContainer const *  p_y) [inline]

Set the Y data set the regression method should use.

Parameters:
p_ydata set to adjust

Definition at line 134 of file STK_IRegress.h.

Referenced by STK::IAAModel::run().

    { p_y_ = p_y;}
template<class YContainer, class XContainer>
void STK::IRegress< YContainer, XContainer >::setX ( XContainer const *  p_x) [inline]

Set the X data set.

Parameters:
p_xdata set of the predictors

Definition at line 140 of file STK_IRegress.h.

Referenced by STK::IAAModel::run().

    { p_x_ = p_x;}
template<class YContainer, class XContainer>
virtual void STK::IRegress< YContainer, XContainer >::preWork ( ) [inline, protected, virtual]

perform any work needed before the call of the regression method.

At this level do nothing.

Definition at line 148 of file STK_IRegress.h.

    { }
template<class YContainer, class XContainer>
void STK::IRegress< YContainer, XContainer >::residuals ( ) [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 156 of file STK_IRegress.h.

Referenced by STK::IRegress< Matrix, Matrix >::run().

    {
       p_residuals_ =  p_y_->clone();
      *p_residuals_ = *p_y_ - *p_predicted_;
    }
template<class YContainer, class XContainer>
virtual void STK::IRegress< YContainer, XContainer >::regression ( ) [private, pure virtual]
template<class YContainer, class XContainer>
virtual void STK::IRegress< YContainer, XContainer >::wregression ( ) [private, pure virtual]
template<class YContainer, class XContainer>
virtual void STK::IRegress< YContainer, XContainer >::prediction ( ) [private, pure virtual]

Compute the predicted outputs by the regression function and store the result in the p_predicted_ container.

Implemented in STK::AdditiveBSplineRegression, STK::BSplineRegression, and STK::MultidimRegression.

Referenced by STK::IRegress< YContainer, Matrix >::run(), and STK::IRegress< Matrix, Matrix >::run().

template<class YContainer, class XContainer>
void STK::IRegress< YContainer, XContainer >::clear ( ) [inline, private]

delete allocated memory.

Definition at line 171 of file STK_IRegress.h.

Referenced by STK::IRegress< Matrix, Matrix >::run(), and STK::IRegress< Matrix, Matrix >::~IRegress().


Member Data Documentation

template<class YContainer, class XContainer>
YContainer const* STK::IRegress< YContainer, XContainer >::p_y_ [protected]
template<class YContainer, class XContainer>
XContainer const* STK::IRegress< YContainer, XContainer >::p_x_ [protected]

Container of the regressors.

Definition at line 56 of file STK_IRegress.h.

Referenced by STK::IRegress< Matrix, Matrix >::setData(), and STK::IRegress< Matrix, Matrix >::setX().

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

weigths of the samples.

Definition at line 58 of file STK_IRegress.h.

Referenced by STK::IRegress< YContainer, Matrix >::run(), and STK::IRegress< Matrix, Matrix >::run().


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