Changeset 270 for bdm/estim/arx.cpp

Show
Ignore:
Timestamp:
02/16/09 10:02:08 (15 years ago)
Author:
smidl
Message:

Changes in the very root classes!
* rv and rvc are no longer compulsory,
* samplecond does not return ll
* BM has drv

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • bdm/estim/arx.cpp

    r254 r270  
    11#include "arx.h" 
    22 
    3 namespace bdm{ 
     3namespace bdm { 
    44 
    55void ARX::bayes ( const vec &dt, const double w ) { 
     
    4444} 
    4545 
    46 ARX* ARX::_copy_ ( bool changerv ) { 
     46ARX* ARX::_copy_ ( ) { 
    4747        ARX* Tmp=new ARX ( *this ); 
    48         if ( changerv ) {Tmp->rv.newids(); Tmp->est._renewrv ( Tmp->rv );} 
    4948        return Tmp; 
    5049} 
     
    5453 
    5554        it_assert_debug ( V.rows() ==A0->V.rows(),"ARX::set_statistics Statistics  differ" ); 
    56         set_parameters ( A0->V,A0->nu ); 
     55        set_statistics ( A0->dimx, A0->V, A0->nu ); 
    5756} 
    5857 
    59 enorm<ldmat>* ARX::predictor ( const RV &rv, const vec &rgr ) const { 
    60         mat mu ( rv.count(), V.rows()-rv.count() ); 
    61         mat R ( rv.count(),rv.count() ); 
     58enorm<ldmat>* ARX::epredictor ( const vec &rgr ) const { 
     59        int dim=est.dimension(); 
     60        mat mu ( dim, V.rows()-dim ); 
     61        mat R ( dim,dim ); 
     62 
    6263        enorm<ldmat>* tmp; 
    63         tmp=new enorm<ldmat> ( rv ); 
     64        tmp=new enorm<ldmat> ( ); 
     65        //TODO: too hackish 
     66        if ( drv._dsize() >0 ) { 
     67        } 
    6468 
    6569        est.mean_mat ( mu,R ); //mu = 
     
    7175} 
    7276 
    73 mlnorm<ldmat>* ARX::predictor ( const RV &rv, const RV &rvc ) const { 
    74         int dif=V.rows() - rv.count() - rvc.count(); 
     77mlnorm<ldmat>* ARX::predictor ( ) const { 
     78        int dim=est.dimension(); 
     79        int dif=V.rows() - dim ;///<----------- TODO 
    7580        it_assert_debug ( ( dif==0 ) || ( dif==1 ), "Give RVs do not match" ); 
    7681 
    77         mat mu ( rv.count(), V.rows()-rv.count() ); 
    78         mat R ( rv.count(),rv.count() ); 
     82        mat mu ( dim, V.rows()-dim ); 
     83        mat R ( dim,dim ); 
    7984        mlnorm<ldmat>* tmp; 
    80         tmp=new mlnorm<ldmat> ( rv,rvc ); 
     85        tmp=new mlnorm<ldmat> ( ); 
    8186 
    8287        est.mean_mat ( mu,R ); //mu = 
     
    8590 
    8691        if ( dif==0 ) { // no constant term 
    87                 tmp->set_parameters ( mu, zeros ( rv.count() ), ldmat ( R ) ); 
     92                tmp->set_parameters ( mu, zeros ( dim ), ldmat ( R ) ); 
    8893        } 
    8994        else { 
    9095                //Assume the constant term is the last one: 
    91                 tmp->set_parameters ( mu.get_cols (0,mu.cols()-2 ), mu.get_col ( mu.cols()-1 ), ldmat ( R ) ); 
     96                tmp->set_parameters ( mu.get_cols ( 0,mu.cols()-2 ), mu.get_col ( mu.cols()-1 ), ldmat ( R ) ); 
    9297        } 
    9398        return tmp; 
    9499} 
    95100 
    96 mlstudent* ARX::predictor_student ( const RV &rv, const RV &rvc ) const { 
    97         int dif=V.rows() - rv.count() - rvc.count(); 
     101mlstudent* ARX::predictor_student ( ) const { 
     102        int dim = est.dimension(); 
     103        int dif=V.rows() - est.dimension();//-------------TODO 
    98104        it_assert_debug ( ( dif==0 ) || ( dif==1 ), "Give RVs do not match" ); 
    99105 
    100         mat mu ( rv.count(), V.rows()-rv.count() ); 
    101         mat R ( rv.count(),rv.count() ); 
     106        mat mu ( dim, V.rows()-dim ); 
     107        mat R ( dim,dim ); 
    102108        mlstudent* tmp; 
    103         tmp=new mlstudent ( rv,rvc ); 
     109        tmp=new mlstudent ( ); 
    104110 
    105111        est.mean_mat ( mu,R ); // 
    106112        mu = mu.T(); 
    107          
    108         int xdim = rv.count(); 
     113 
     114        int xdim = dimx; 
    109115        int end = V._L().rows()-1; 
    110116        ldmat Lam ( V._L() ( xdim,end,xdim,end ), V._D() ( xdim,end ) );  //exp val of R 
     
    112118 
    113119        if ( dif==0 ) { // no constant term 
    114                 tmp->set_parameters ( mu, zeros ( rv.count() ), ldmat ( R ), Lam); 
     120                tmp->set_parameters ( mu, zeros ( xdim ), ldmat ( R ), Lam ); 
    115121        } 
    116122        else { 
    117123                //Assume the constant term is the last one: 
    118                 tmp->set_parameters ( mu.get_cols (0,mu.cols()-2 ), mu.get_col ( mu.cols()-1 ), ldmat ( R ), Lam); 
     124                if ( mu.cols() >1 ) { 
     125                        tmp->set_parameters ( mu.get_cols ( 0,mu.cols()-2 ), mu.get_col ( mu.cols()-1 ), ldmat ( R ), Lam ); 
     126                } 
     127                else { 
     128                        tmp->set_parameters ( mat(dim,0), mu.get_col ( mu.cols()-1 ), ldmat ( R ), Lam ); 
     129                } 
    119130        } 
    120131        return tmp; 
     
    178189 
    179190ivec ARX::structure_est ( egiw est0 ) { 
    180         ivec ind=linspace ( 1,rv.count()-1 ); 
     191        ivec ind=linspace ( 1,est.dimension()-1 ); 
    181192        egiw_bestbelow ( est, est0, est.lognc()- est0.lognc(), ind ); 
    182193        return ind;