- 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;
    00062 public:
    00065         ARX ( const double frg0 = 1.0 ) : BMEF ( frg0 ), est (), V ( est._V() ), nu ( est._nu() ) {};
    00066         ARX ( const ARX &A0 ) : BMEF (), est (), V ( est._V() ), nu ( est._nu() ) {
    00067                 set_statistics ( A0.dimx, A0.V, A0.nu );
    00068                 set_parameters ( A0.frg );
    00069         };
    00070         ARX* _copy_() const;
    00071         void set_parameters ( double frg0 ) {
    00072                 frg = frg0;
    00073         }
    00074         void set_statistics ( int dimx0, const ldmat V0, double nu0 = -1.0 ) {
    00075                 est.set_parameters ( dimx0, V0, nu0 );
    00076                 last_lognc = est.lognc();
    00077                 dimx = dimx0;
    00078         }
    00080
    00082         void set_statistics ( const BMEF* BM0 );
    00083
    00086
    00088         void bayes ( const vec &dt, const double w );
    00089         void bayes ( const vec &dt ) {
    00090                 bayes ( dt, 1.0 );
    00091         };
    00092         double logpred ( const vec &dt ) const;
    00093         void flatten ( const BMEF* B ) {
    00094                 const ARX* A = dynamic_cast<const ARX*> ( B );
    00095                 // nu should be equal to B.nu
    00096                 est.pow ( A->nu / nu );
    00097                 if ( evalll ) {
    00098                         last_lognc = est.lognc();
    00099                 }
    00100         }
    00102         enorm<ldmat>* epredictor ( const vec &rgr ) const;
    00104         enorm<ldmat>* epredictor() const {
    00105                 bdm_assert_debug ( dimx == V.rows() - 1, "Regressor is not only 1" );
    00106                 return epredictor ( vec_1 ( 1.0 ) );
    00107         }
    00109         mlnorm<ldmat>* predictor() const;
    00110         mlstudent* predictor_student() const;
    00112         ivec structure_est ( egiw Eg0 );
    00114         ivec structure_est_LT ( egiw Eg0 );
    00116
    00119         const egiw& posterior() const {
    00120                 return est;
    00121         }
    00123
    00126         void set_rv ( const RV &yrv0 , const RV &rgrrv0 ) {
    00127                 _yrv = yrv0;
    00128                 rgrrv=rgrrv0;
    00129                 set_drv(concat(yrv0, rgrrv));
    00130         }
    00131
    00132         RV& get_yrv() {
    00133                 //if yrv is not ready create it
    00134                 if ( _yrv._dsize() != dimx ) {
    00135                         int i = 0;
    00136                         while ( _yrv._dsize() < dimx ) {
    00137                                 _yrv.add ( drv ( vec_1 ( i ) ) );
    00138                                 i++;
    00139                         }
    00140                 }
    00141                 //yrv should be ready by now
    00142                 bdm_assert_debug ( _yrv._dsize() == dimx, "incompatible drv" );
    00143                 return _yrv;
    00144         }
    00146
    00167         void from_setting ( const Setting &set );
    00168
    00169         void validate() {
    00170                 bdm_assert(dimx == _yrv._dsize(), "RVs of parameters and regressor do not match");
    00171
    00172         }
    00173 };
    00174
    00175 UIREGISTER ( ARX );
    00176 SHAREDPTR ( ARX );
    00177
    00178 }
    00179
    00180 #endif // AR_H
    00181
    00182