- 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
    00127                 const egiw& posterior() const {
    00128                 return est;
    00129         }
    00131
    00134         void set_rv ( const RV &yrv0 , const RV &rgrrv0 ) {
    00135                 _yrv = yrv0;
    00136                 rgrrv=rgrrv0;
    00137                 set_drv(concat(yrv0, rgrrv));
    00138         }
    00139
    00140         RV& get_yrv() {
    00141                 //if yrv is not ready create it
    00142                 if ( _yrv._dsize() != dimx ) {
    00143                         int i = 0;
    00144                         while ( _yrv._dsize() < dimx ) {
    00145                                 _yrv.add ( drv ( vec_1 ( i ) ) );
    00146                                 i++;
    00147                         }
    00148                 }
    00149                 //yrv should be ready by now
    00150                 bdm_assert_debug ( _yrv._dsize() == dimx, "incompatible drv" );
    00151                 return _yrv;
    00152         }
    00154
    00175         void from_setting ( const Setting &set );
    00176
    00177         void validate() {
    00178                 bdm_assert(dimx == _yrv._dsize(), "RVs of parameters and regressor do not match");
    00179
    00180         }
    00181 };
    00182
    00183 UIREGISTER ( ARX );
    00184 SHAREDPTR ( ARX );
    00185
    00189 class ARXfrg : public ARX{
    00190         public:
    00191                 ARXfrg():ARX(){};
    00193                 ARXfrg(const ARXfrg &A0):ARX(A0){};
    00194                 ARXfrg* _copy_() const {ARXfrg *A = new ARXfrg(*this); return A;}
    00195         void condition(const vec &val){
    00196                 frg = val(0);
    00197         }
    00198 };
    00199 UIREGISTER(ARXfrg);
    00200 };
    00201 #endif // AR_H
    00202
    00203