- Timestamp:
- 09/02/10 14:40:42 (14 years ago)
- Location:
- library
- Files:
-
- 4 modified
Legend:
- Unmodified
- Added
- Removed
-
library/bdm/estim/arx.cpp
r1166 r1176 144 144 } 145 145 146 mlstudent* ARX::predictor_student ( ) const { 146 estudent<ldmat>* ARX::epredictor_student ( const vec &cond ) const { 147 bdm_assert_debug ( cond.length() == rgrlen , "ARX::epredictor cond is of size "+num2str(cond.length())+" expected dimension is "+num2str(rgrlen) ); 148 149 mat mu ( dimy, posterior()._V().rows() - dimy ); 150 151 vec ext_rgr; 152 if (have_constant) { 153 ext_rgr = concat(cond,vec_1(1.0)); 154 } else { 155 ext_rgr = cond; 156 } 157 158 estudent<ldmat>* tmp = new estudent<ldmat> ( ); 159 //TODO: too hackish 160 if ( yrv._dsize() > 0 ) { 161 } 162 163 ldmat Lam; 164 ldmat Vz; 165 166 est.factorize( mu, Vz, Lam ); //mu = 167 //correction for student-t -- TODO check if correct!! 168 double zeta =0; 169 if (mu.cols()>0) {// nonempty egiw 170 mat p_mu = mu.T() * ext_rgr; //the result is one column 171 tmp->_mu()= p_mu.get_col ( 0 ); 172 zeta = Vz.invqform(ext_rgr); 173 } else { 174 tmp->_mu()=zeros(dimy); 175 } 176 // nu-rgrlen+2+dimy = delta+dimy 177 tmp->_delta()=est._nu()+2-rgrlen; 178 tmp->_H()=Lam; 179 tmp->_H()*=1/tmp->_delta(); 180 tmp->_H()*=(1+zeta); 181 182 if (dimy==yrv._dsize()) 183 tmp->set_rv(yrv); 184 return tmp; 185 } 186 187 mlstudent* ARX::predictor ( ) const { 147 188 const ldmat &V = posterior()._V(); 148 189 -
library/bdm/estim/arx.h
r1166 r1176 93 93 //! Conditioned version of the predictor 94 94 enorm<ldmat>* epredictor ( const vec &rgr ) const; 95 //! conditional version of the predictor 95 estudent<ldmat>* epredictor_student ( const vec &rgr ) const; 96 //! conditional version of the predictor 96 97 template<class sq_T> 97 98 shared_ptr<mlnorm<sq_T> > ml_predictor() const; … … 99 100 template<class sq_T> 100 101 void ml_predictor_update ( mlnorm<sq_T> &pred ) const; 101 mlstudent* predictor _student() const;102 mlstudent* predictor() const; 102 103 //! Brute force structure estimation.\return indices of accepted regressors. 103 104 ivec structure_est ( const egiw &Eg0 ); -
library/tests/stresssuite/arx_elem_stress.cpp
r1064 r1176 39 39 X2.set_row ( 0, x ); 40 40 41 mlstudent* Ap = Ar.predictor _student();41 mlstudent* Ap = Ar.predictor(); 42 42 vec Ap_x = Ap->evallogcond_mat ( X, empty_vec ); 43 43 vec ll_x = Ar.logpred_mat ( X2 , empty_vec); -
library/tests/stresssuite/arx_stress.cpp
r1064 r1176 55 55 56 56 // Build predictor 57 mlstudent* Pr = Ar.predictor_student ( ); 58 // Test similarity of likelihoods from the Bayes rule and the predictor 57 mlstudent* Pr = Ar.predictor ( ); 58 estudent<ldmat>* PrS = Ar.epredictor_student (rgr ); 59 60 cout << "m1: " << Pr->_A()*rgr+Pr->_mu_const() << 61 " v1:" << Pr->e()._R(); 62 cout << "ms: " << PrS->mean() << " vs:" << PrS->variance() << 63 " del:" << PrS->_delta() <<endl; 64 65 // Test similarity of likelihoods from the Bayes rule and the predictor 59 66 cout << "BR log-lik: " << Ar._ll(); 60 cout << " , predictor ll: " << Pr->evallogcond ( vec_1 ( Yt ( t ) ), rgr ) << endl; 61 delete Pr; 62 } 67 cout << " , predictor ll: " << Pr->evallogcond ( vec_1 ( Yt ( t ) ), rgr ); 68 cout << " , epredictor_student ll: " << PrS->evallog ( vec_1 ( Yt ( t ) ) ) << endl; 69 delete Pr; 70 delete PrS; 71 } 63 72 //print posterior moments 64 73 cout << "posterior mean: " << f_thr.mean() << endl;