- Main Page
- Related Pages
- Classes
- Files

- File List
- File Members

# arx.h

Go to the documentation of this file.

    00001
    00013 #ifndef AR_H
    00014 #define AR_H
    00015
    00016 #include "../math/functions.h"
    00017 #include "../stat/exp_family.h"
    00018 #include "../base/user_info.h"
    00019 //#include "../estim/kalman.h"
    00020 #include "arx_straux.h"
    00021
    00022 namespace bdm {
    00023
    00043 class ARX: public BMEF {
    00044 protected:
    00046         int dimx;
    00049         RV _yrv;
    00051         RV rgrrv;
    00053         egiw est;
    00055         ldmat &V;
    00057         double &nu;
    00059         bool have_constant;
    00061         vec _dt;
    00063         egiw alter_est;
    00064 public:
    00067         ARX ( const double frg0 = 1.0 ) : BMEF ( frg0 ), est (), V ( est._V() ), nu ( est._nu() ), have_constant(true), _dt() {};
    00068         ARX ( const ARX &A0 ) : BMEF (A0.frg), est (A0.est), V ( est._V() ), nu ( est._nu() ), have_constant(A0.have_constant), _dt(A0._dt) {
    00069                 dimx = A0.dimx;
    00070                 _yrv = A0._yrv;
    00071                 rgrrv = A0.rgrrv;
    00072                 set_drv(A0._drv());
    00073         };
    00074         ARX* _copy_() const;
    00075         void set_parameters ( double frg0 ) {
    00076                 frg = frg0;
    00077         }
    00078         void set_constant ( bool const0 ) {
    00079                 have_constant=const0;
    00080         }
    00081         void set_statistics ( int dimx0, const ldmat V0, double nu0 = -1.0 ) {
    00082                 est.set_parameters ( dimx0, V0, nu0 );
    00083                 last_lognc = est.lognc();
    00084                 dimx = dimx0;
    00085         }
    00087
    00089         void set_statistics ( const BMEF* BM0 );
    00090
    00093
    00095         void bayes ( const vec &dt, const double w );
    00096         void bayes ( const vec &dt ) {
    00097                 bayes ( dt, 1.0 );
    00098         };
    00099         double logpred ( const vec &dt ) const;
    00100         void flatten ( const BMEF* B ) {
    00101                 const ARX* A = dynamic_cast<const ARX*> ( B );
    00102                 // nu should be equal to B.nu
    00103                 est.pow ( A->nu / nu );
    00104                 if ( evalll ) {
    00105                         last_lognc = est.lognc();
    00106                 }
    00107         }
    00109         enorm<ldmat>* epredictor ( const vec &rgr ) const;
    00111         enorm<ldmat>* epredictor() const {
    00112                 bdm_assert_debug ( dimx == V.rows() - 1, "Regressor is not only 1" );
    00113                 return epredictor ( vec_1 ( 1.0 ) );
    00114         }
    00116         mlnorm<ldmat>* predictor() const;
    00117         mlstudent* predictor_student() const;
    00119         ivec structure_est ( egiw Eg0 );
    00121         ivec structure_est_LT ( egiw Eg0 );
    00123
    00126         const egiw& posterior() const {
    00127                 return est;
    00128         }
    00130
    00133         void set_rv ( const RV &yrv0 , const RV &rgrrv0 ) {
    00134                 _yrv = yrv0;
    00135                 rgrrv=rgrrv0;
    00136                 set_drv(concat(yrv0, rgrrv));
    00137         }
    00138
    00139         RV& get_yrv() {
    00140                 //if yrv is not ready create it
    00141                 if ( _yrv._dsize() != dimx ) {
    00142                         int i = 0;
    00143                         while ( _yrv._dsize() < dimx ) {
    00144                                 _yrv.add ( drv ( vec_1 ( i ) ) );
    00145                                 i++;
    00146                         }
    00147                 }
    00148                 //yrv should be ready by now
    00149                 bdm_assert_debug ( _yrv._dsize() == dimx, "incompatible drv" );
    00150                 return _yrv;
    00151         }
    00153
    00174         void from_setting ( const Setting &set );
    00175
    00176         void validate() {
    00177                 bdm_assert(dimx == _yrv._dsize(), "RVs of parameters and regressor do not match");
    00178
    00179         }
    00180 };
    00181
    00182 UIREGISTER ( ARX );
    00183 SHAREDPTR ( ARX );
    00184
    00188 class ARXfrg : public ARX{
    00189         public:
    00190                 ARXfrg():ARX(){};
    00191                 ARXfrg(const ARXfrg &A0):ARX(A0){};
    00192                 ARXfrg* _copy_() const {ARXfrg *A = new ARXfrg(*this); return A;}
    00193         void condition(const vec &val){
    00194                 frg = val(0);
    00195         }
    00196 };
    00197 UIREGISTER(ARXfrg);
    00198 };
    00199 #endif // AR_H
    00200
    00201