root/bdm/estim/arx.h @ 262

Revision 262, 3.2 kB (checked in by smidl, 15 years ago)

cleanup of include files

  • Property svn:eol-style set to native
Line 
1/*!
2  \file
3  \brief Bayesian Filtering for generalized autoregressive (ARX) model
4  \author Vaclav Smidl.
5
6  -----------------------------------
7  BDM++ - C++ library for Bayesian Decision Making under Uncertainty
8
9  Using IT++ for numerical operations
10  -----------------------------------
11*/
12
13#ifndef AR_H
14#define AR_H
15
16#include "../stat/libFN.h"
17#include "../stat/libEF.h"
18
19namespace bdm{
20
21/*!
22* \brief Linear Autoregressive model with Gaussian noise
23
24Regression of the following kind:
25\f[
26y_t = \theta_1 \psi_1 + \theta_2 + \psi_2 +\ldots + \theta_n \psi_n + r e_t
27\f]
28where unknown parameters \c rv are \f$[\theta r]\f$, regression vector \f$\psi=\psi(y_{1:t},u_{1:t})\f$ is a known function of past outputs and exogeneous variables \f$u_t\f$. Distrubances \f$e_t\f$ are supposed to be normally distributed:
29\f[
30e_t \sim \mathcal{N}(0,1).
31\f]
32
33Extension for time-variant parameters \f$\theta_t,r_t\f$ may be achived using exponential forgetting (Kulhavy and Zarrop, 1993). In such a case, the forgetting factor \c frg \f$\in <0,1>\f$ should be given in the constructor. Time-invariant parameters are estimated for \c frg = 1.
34*/
35class ARX: public BMEF {
36protected:
37        //! Posterior estimate of \f$\theta,r\f$ in the form of Normal-inverse Wishart density
38        egiw est;
39        //! cached value of est.V
40        ldmat &V;
41        //! cached value of est.nu
42        double &nu;
43public:
44        //! Full constructor
45        ARX ( const RV &rv, const mat &V0, const double &nu0, const double frg0=1.0 ) : BMEF ( rv,frg0 ),est ( rv,V0,nu0 ), V ( est._V() ), nu ( est._nu() )
46        {last_lognc=est.lognc();};
47
48        //!Copy constructor
49        ARX ( const ARX &A0 ) : BMEF ( A0),est ( rv,A0.V,A0.nu ), V ( est._V() ), nu ( est._nu() ) {};
50
51        //!Auxiliary function
52        ARX* _copy_(bool changerv=false);
53       
54//      //! Set parameters given by moments, \c mu (mean of theta), \c R (mean of R) and \c C (variance of theta)
55//      void set_parameters ( const vec &mu, const mat &R, const mat &C, double dfm){};
56        //! Set sufficient statistics
57        void set_parameters ( const ldmat &V0, const double &nu0 )
58        {est._V() =V0;est._nu() =nu0;last_lognc=est.lognc();}
59        void set_statistics ( const BMEF* BM0 );
60        //! Returns sufficient statistics
61        void get_parameters ( mat &V0, double &nu0 ) {V0=est._V().to_mat(); nu0=est._nu();}
62        //! Here \f$dt = [y_t psi_t] \f$.
63        void bayes ( const vec &dt, const double w );
64        void bayes ( const vec &dt ) {bayes ( dt,1.0 );};
65        const epdf& _epdf() const {return est;}
66        double logpred ( const vec &dt ) const;
67        void flatten (const BMEF* B ) {
68                const ARX* A=dynamic_cast<const ARX*>(B);
69                // nu should be equal to B.nu
70                est.pow ( A->nu/nu);
71                if(evalll){last_lognc=est.lognc();}
72        }
73        //! Conditioned version of the predictor
74        enorm<ldmat>* predictor(const RV &rv0, const vec &rgr) const; 
75        enorm<ldmat>* predictor(const RV &rv0) const {it_assert_debug(rv0.count()==V.rows()-1,"Regressor is not only 1");return predictor(rv0,vec_1(1.0));}
76        //! conditional version of the predictor
77        mlnorm<ldmat>* predictor(const RV &rv0, const RV &rvc0) const;
78        mlstudent* predictor_student(const RV &rv0, const RV &rvc0) const;
79        //! Brute force structure estimation.\return indeces of accepted regressors.
80        ivec structure_est ( egiw Eg0 );
81        const egiw* _e() const {return &est ;};
82};
83
84}
85
86#endif // AR_H
87
Note: See TracBrowser for help on using the browser.