root/library/bdm/estim/arx_ext.h @ 804

Revision 804, 2.4 kB (checked in by smidl, 14 years ago)

extended ARX

Line 
1/*!
2  \file
3  \brief Bayesian Filtering for extensions of autoregressive (ARX) model
4  \author Vaclav Smidl.
5
6*/
7
8#ifndef AREX_H
9#define AREX_H
10
11#include "../math/functions.h"
12#include "arx.h"
13
14namespace bdm {
15
16/*!
17* \brief Non-linear transformation + Gaussian noise
18
19Regression of the following kind:
20\f[
21y_t = g(\psi_t ) + r e_t
22\f]
23where unknown parameters \c rv are \f$[r]\f$, regression vector \f$\psi_t=\psi(y_{1:t},u_{1:t})\f$ is propagated through a known function \c g. Distrubances \f$e_t\f$ are supposed to be normally distributed:
24\f[
25e_t \sim \mathcal{N}(0,1).
26\f]
27
28*/
29class ARXg: public ARX {
30protected:
31        //! function g
32        shared_ptr<fnc> g;
33public:
34        //! \name Constructors
35        //!@{
36                ARXg (): ARX(){}
37                ARXg (const ARXg &A0): ARX(A0),g(A0.g){}
38                ARXg* _copy() const {return new ARXg(*this);}
39        //!@}
40
41        //!\name Mathematical operations
42        //!@{
43
44        //! Weighted Bayes \f$ dt = [y_t psi_t] \f$.
45        void bayes_weighted ( const vec &yt, const vec &cond = empty_vec, const double w = 1.0 ){
46                int dimc_store =dimc;
47                dimc =0;
48                ARX::bayes_weighted(yt - g->eval(cond), empty_vec, w);
49                dimc = dimc_store;
50        };
51        //!@}
52
53        /*! UI for ARXg estimator
54
55        \code
56        class = 'ARXg';
57        rv    = RV({names_of_dt} )                 // description of output variables
58        rgr   = RV({names_of_regressors}, [-1,-2]} // description of regressor variables
59        constant = 1;                              // 0/1 switch if the constant term is modelled or not
60        g     = {class='my_function',...}          // function transforming regressor
61
62        --- optional ---
63        prior = {class='egiw',...};                // Prior density, when given default is used instead
64        alternative = {class='egiw',...};          // Alternative density in stabilized estimation, when not given prior is used
65
66        frg = 1.0;                                 // forgetting, default frg=1.0
67
68        rv_param   = RV({names_of_parameters}}     // description of parametetr names
69                                                                                           // default: ["theta_i" and "r_i"]
70        \endcode
71        */
72        void from_setting ( const Setting &set ){
73                ARX::from_setting(set);
74                g=UI::build<fnc>(set,"g",UI::compulsory);
75        }
76
77        void validate() {
78                ARX::validate();//if dimc not set set it from V
79                bdm_assert(g->dimension()==dimensiony(),"incompatible g");
80                bdm_assert(g->dimensionc()==dimensionc(),"incompatible g");
81        }
82
83        void to_setting ( Setting &set ) const
84        {                       
85                ARX::to_setting( set ); // takes care of rv, yrv, rvc
86                UI::save(g,set,"g");           
87        } 
88};
89UIREGISTER ( ARXg );
90SHAREDPTR ( ARXg );
91
92};
93#endif // AREX_H
94
Note: See TracBrowser for help on using the browser.