Changeset 270 for bdm/estim/arx.cpp
- Timestamp:
- 02/16/09 10:02:08 (15 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
bdm/estim/arx.cpp
r254 r270 1 1 #include "arx.h" 2 2 3 namespace bdm {3 namespace bdm { 4 4 5 5 void ARX::bayes ( const vec &dt, const double w ) { … … 44 44 } 45 45 46 ARX* ARX::_copy_ ( bool changerv) {46 ARX* ARX::_copy_ ( ) { 47 47 ARX* Tmp=new ARX ( *this ); 48 if ( changerv ) {Tmp->rv.newids(); Tmp->est._renewrv ( Tmp->rv );}49 48 return Tmp; 50 49 } … … 54 53 55 54 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 ); 57 56 } 58 57 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() ); 58 enorm<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 62 63 enorm<ldmat>* tmp; 63 tmp=new enorm<ldmat> ( rv ); 64 tmp=new enorm<ldmat> ( ); 65 //TODO: too hackish 66 if ( drv._dsize() >0 ) { 67 } 64 68 65 69 est.mean_mat ( mu,R ); //mu = … … 71 75 } 72 76 73 mlnorm<ldmat>* ARX::predictor ( const RV &rv, const RV &rvc ) const { 74 int dif=V.rows() - rv.count() - rvc.count(); 77 mlnorm<ldmat>* ARX::predictor ( ) const { 78 int dim=est.dimension(); 79 int dif=V.rows() - dim ;///<----------- TODO 75 80 it_assert_debug ( ( dif==0 ) || ( dif==1 ), "Give RVs do not match" ); 76 81 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 ); 79 84 mlnorm<ldmat>* tmp; 80 tmp=new mlnorm<ldmat> ( rv,rvc);85 tmp=new mlnorm<ldmat> ( ); 81 86 82 87 est.mean_mat ( mu,R ); //mu = … … 85 90 86 91 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 ) ); 88 93 } 89 94 else { 90 95 //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 ) ); 92 97 } 93 98 return tmp; 94 99 } 95 100 96 mlstudent* ARX::predictor_student ( const RV &rv, const RV &rvc ) const { 97 int dif=V.rows() - rv.count() - rvc.count(); 101 mlstudent* ARX::predictor_student ( ) const { 102 int dim = est.dimension(); 103 int dif=V.rows() - est.dimension();//-------------TODO 98 104 it_assert_debug ( ( dif==0 ) || ( dif==1 ), "Give RVs do not match" ); 99 105 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 ); 102 108 mlstudent* tmp; 103 tmp=new mlstudent ( rv,rvc);109 tmp=new mlstudent ( ); 104 110 105 111 est.mean_mat ( mu,R ); // 106 112 mu = mu.T(); 107 108 int xdim = rv.count();113 114 int xdim = dimx; 109 115 int end = V._L().rows()-1; 110 116 ldmat Lam ( V._L() ( xdim,end,xdim,end ), V._D() ( xdim,end ) ); //exp val of R … … 112 118 113 119 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 ); 115 121 } 116 122 else { 117 123 //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 } 119 130 } 120 131 return tmp; … … 178 189 179 190 ivec ARX::structure_est ( egiw est0 ) { 180 ivec ind=linspace ( 1, rv.count()-1 );191 ivec ind=linspace ( 1,est.dimension()-1 ); 181 192 egiw_bestbelow ( est, est0, est.lognc()- est0.lognc(), ind ); 182 193 return ind;