bdm::ARX Class Reference

Linear Autoregressive model with Gaussian noise. More...

#include <arx.h>

List of all members.

Public Member Functions

void set_statistics (const BMEF *BM0)
 Set sufficient statistics.
void from_setting (const Setting &set)
virtual string to_string ()
 This method returns a basic info about the current instance.
virtual void to_setting (Setting &set) const
 This method save all the instance properties into the Setting structure.
virtual void validate ()
 This method TODO.
Constructors
 ARX (const double frg0=1.0)
 ARX (const ARX &A0)
ARX_copy_ () const
 Flatten the posterior as if to keep nu0 data.
void set_parameters (double frg0)
void set_statistics (int dimx0, const ldmat V0, double nu0=-1.0)
Mathematical operations
void bayes (const vec &dt, const double w)
 Weighted Bayes $ dt = [y_t psi_t] $.
void bayes (const vec &dt)
 Incremental Bayes rule.
double logpred (const vec &dt) const
void flatten (const BMEF *B)
 Flatten the posterior according to the given BMEF (of the same type!).
enorm< ldmat > * epredictor (const vec &rgr) const
 Conditioned version of the predictor.
enorm< ldmat > * epredictor () const
 Predictor for empty regressor.
mlnorm< ldmat > * predictor () const
 conditional version of the predictor
mlstudentpredictor_student () const
ivec structure_est (egiw Eg0)
 Brute force structure estimation.
Access attributes
const egiw_e () const
const egiwposterior () const
Connection
void set_drv (const RV &drv0)
RVget_yrv ()
Mathematical operations
virtual void bayesB (const mat &Dt)
 Batch Bayes rule (columns of Dt are observations).
vec logpred_m (const mat &dt) const
 Matrix version of logpred.
Access to attributes
const RV_drv () const
void set_rv (const RV &rv)
double _ll () const
void set_evalll (bool evl0)

Protected Attributes

int dimx
 size of output variable (needed in regressors)
RV _yrv
egiw est
 Posterior estimate of $\theta,r$ in the form of Normal-inverse Wishart density.
ldmatV
 cached value of est.V
double & nu
 cached value of est.nu
double frg
 forgetting factor
double last_lognc
 cached value of lognc() in the previous step (used in evaluation of ll )
RV drv
 Random variable of the data (optional).
double ll
 Logarithm of marginalized data likelihood.
bool evalll
 If true, the filter will compute likelihood of the data record and store it in ll . Set to false if you want to save computational time.

Extension to conditional BM

This extension is useful e.g. in Marginalized Particle Filter (bdm::MPF). Alternatively, it can be used for automated connection to DS when the condition is observed

const RV_rvc () const
 access function
virtual void condition (const vec &val)
 Substitute val for rvc.
RV rvc
 Name of extension variable.

Logging of results

virtual void set_options (const string &opt)
 Set boolean options from a string, recognized are: "logbounds,logll".
virtual void log_add (logger &L, const string &name="")
 Add all logged variables to a logger.
virtual void logit (logger &L)
ivec LIDs
 IDs of storages in loggers 4:[1=mean,2=lb,3=ub,4=ll].
ivec LFlags
 Flags for logging - same size as LIDs, each entry correspond to the same in LIDs.


Detailed Description

Linear Autoregressive model with Gaussian noise.

Regression of the following kind:

\[ y_t = \theta_1 \psi_1 + \theta_2 + \psi_2 +\ldots + \theta_n \psi_n + r e_t \]

where unknown parameters rv are $[\theta r]$, regression vector $\psi=\psi(y_{1:t},u_{1:t})$ is a known function of past outputs and exogeneous variables $u_t$. Distrubances $e_t$ are supposed to be normally distributed:

\[ e_t \sim \mathcal{N}(0,1). \]

See Theory of ARX model estimation for mathematical treatment.

The easiest way how to use the class is:

#include "estim/arx.h"
using namespace bdm;
        
// estimation of AR(0) model
int main() {
        //prior 
        mat V0 = 0.00001*eye(2); V0(0,0)= 0.1; //
        ARX Ar; 
        Ar.set_statistics(1, V0); //nu is default (set to have finite moments)
                                                          // forgetting is default: 1.0
        mat Data = concat_vertical( randn(1,100), ones(1,100) );
        Ar.bayesB( Data); 
                        
        cout << "Expected value of Theta is: " << Ar.posterior().mean() <<endl;
}

Todo:
sort out constant terms - bayes should accept vec without additional 1s

Member Function Documentation

void bdm::ARX::bayes ( const vec &  dt  )  [inline, virtual]

Incremental Bayes rule.

Parameters:
dt vector of input data

Reimplemented from bdm::BMEF.

References bayes().

Referenced by bayes().

void bdm::ARX::from_setting ( const Setting &  set  )  [virtual]

UI for ARX estimator

The ARX is constructed from a structure with fields:

        estimator = {
                type = "ARX";
                y = {type="rv", ...}   // description of output variables
                rgr = {type="rv", ...} // description of regressor variables
                constant = true;       // boolean switch if the constant term is modelled or not

                //optional fields
                dV0 = [1e-3, 1e-5, 1e-5, 1e-5]; 
                                                           // default: 1e-3 for y, 1e-5 for rgr
                nu0 = 6;               // default: rgrlen + 2
                frg = 1.0;             // forgetting, default frg=1.0
        };

The estimator will assign names of the posterior in the form ["theta_i" and "r_i"]

Reimplemented from bdm::root.

References bdm::BMEF::frg, and bdm::UI::get().

double bdm::ARX::logpred ( const vec &  dt  )  const [virtual]

Evaluates predictive log-likelihood of the given data record I.e. marginal likelihood of the data with the posterior integrated out.

Reimplemented from bdm::BM.

References est, bdm::BM::evalll, bdm::BMEF::frg, bdm::BMEF::last_lognc, bdm::egiw::lognc(), nu, ldmat::opupdt(), bdm::egiw::pow(), and V.

mlnorm< ldmat > * bdm::ARX::predictor (  )  const [virtual]

conditional version of the predictor

<----------- TODO

Reimplemented from bdm::BM.

References bdm::epdf::dimension(), est, sqmat::rows(), bdm::mlnorm< sq_T >::set_parameters(), and V.

ivec bdm::ARX::structure_est ( egiw  Eg0  ) 

Brute force structure estimation.

Returns:
indeces of accepted regressors.

References bdm::epdf::dimension(), est, and bdm::egiw::lognc().


Member Data Documentation

RV bdm::ARX::_yrv [protected]

description of modelled data $ y_t $ in the likelihood function Do NOT access directly, only via get_yrv().


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

Generated on Wed Aug 5 00:06:57 2009 for mixpp by  doxygen 1.5.9