- 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_statistics ( int dimx0, const ldmat V0, double nu0 = -1.0 ) {
    00079                 est.set_parameters ( dimx0, V0, nu0 );
    00080                 last_lognc = est.lognc();
    00081                 dimx = dimx0;
    00082         }
    00084
    00086         void set_statistics ( const BMEF* BM0 );
    00087
    00090
    00092         void bayes ( const vec &dt, const double w );
    00093         void bayes ( const vec &dt ) {
    00094                 bayes ( dt, 1.0 );
    00095         };
    00096         double logpred ( const vec &dt ) const;
    00097         void flatten ( const BMEF* B ) {
    00098                 const ARX* A = dynamic_cast<const ARX*> ( B );
    00099                 // nu should be equal to B.nu
    00100                 est.pow ( A->nu / nu );
    00101                 if ( evalll ) {
    00102                         last_lognc = est.lognc();
    00103                 }
    00104         }
    00106         enorm<ldmat>* epredictor ( const vec &rgr ) const;
    00108         enorm<ldmat>* epredictor() const {
    00109                 bdm_assert_debug ( dimx == V.rows() - 1, "Regressor is not only 1" );
    00110                 return epredictor ( vec_1 ( 1.0 ) );
    00111         }
    00113         mlnorm<ldmat>* predictor() const;
    00114         mlstudent* predictor_student() const;
    00116         ivec structure_est ( egiw Eg0 );
    00118         ivec structure_est_LT ( egiw Eg0 );
    00120
    00123         const egiw& posterior() const {
    00124                 return est;
    00125         }
    00127
    00130         void set_rv ( const RV &yrv0 , const RV &rgrrv0 ) {
    00131                 _yrv = yrv0;
    00132                 rgrrv=rgrrv0;
    00133                 set_drv(concat(yrv0, rgrrv));
    00134         }
    00135
    00136         RV& get_yrv() {
    00137                 //if yrv is not ready create it
    00138                 if ( _yrv._dsize() != dimx ) {
    00139                         int i = 0;
    00140                         while ( _yrv._dsize() < dimx ) {
    00141                                 _yrv.add ( drv ( vec_1 ( i ) ) );
    00142                                 i++;
    00143                         }
    00144                 }
    00145                 //yrv should be ready by now
    00146                 bdm_assert_debug ( _yrv._dsize() == dimx, "incompatible drv" );
    00147                 return _yrv;
    00148         }
    00150
    00171         void from_setting ( const Setting &set );
    00172
    00173         void validate() {
    00174                 bdm_assert(dimx == _yrv._dsize(), "RVs of parameters and regressor do not match");
    00175
    00176         }
    00177 };
    00178
    00179 UIREGISTER ( ARX );
    00180 SHAREDPTR ( ARX );
    00181
    00185 class ARXfrg : public ARX{
    00186         public:
    00187                 ARXfrg():ARX(){};
    00188                 ARXfrg(const ARXfrg &A0):ARX(A0){};
    00189                 ARXfrg* _copy_() const {ARXfrg *A = new ARXfrg(*this); return A;}
    00190         void condition(const vec &val){
    00191                 frg = val(0);
    00192         }
    00193 };
    00194 UIREGISTER(ARXfrg);
    00195 };
    00196 #endif // AR_H
    00197
    00198