Changeset 990
- Timestamp:
- 05/26/10 18:42:26 (15 years ago)
- Location:
- library/bdm/estim
- Files:
-
- 2 modified
Legend:
- Unmodified
- Added
- Removed
-
library/bdm/estim/arx.cpp
r979 r990 4 4 void ARX::bayes_weighted ( const vec &yt, const vec &cond, const double w ) { 5 5 6 bdm_assert_debug ( yt.length() == dimy, "ARX::bayes yt is smaller then dimensiony()");7 bdm_assert_debug ( (cond.length() == rgrlen - int(have_constant==true)) , "ARX::bayes dimension of cond is not rgrlen");6 bdm_assert_debug ( yt.length() == dimy, "ARX::bayes yt is of size "+num2str(yt.length())+" expected dimension is "+num2str(dimy) ); 7 bdm_assert_debug ( cond.length() == rgrlen , "ARX::bayes cond is of size "+num2str(cond.length())+" expected dimension is "+num2str(rgrlen) ); 8 8 double lnc; 9 9 //cache … … 227 227 dimy = yrv._dsize(); 228 228 bdm_assert(dimy>0,"ARX::yrv should not be empty"); 229 // rgrlen - including constant!!!230 229 rgrlen = rgr._dsize(); 231 230 … … 238 237 dimc = rgrlen; 239 238 rvc = rgr; 240 rgrlen += int ( have_constant == true );241 239 242 240 //init 243 241 shared_ptr<egiw> pri = UI::build<egiw> ( set, "prior", UI::optional ); 244 242 if (pri) 243 set_prior(pri.get()); 244 245 245 shared_ptr<egiw> alt = UI::build<egiw> ( set, "alternative", UI::optional ); 246 246 if ( alt ) { 247 247 bdm_assert ( alt->_dimx() == dimy, "alternative is not compatible" ); 248 bdm_assert ( alt->_V().rows() == dimy + rgrlen , "alternative is not compatible" );248 bdm_assert ( alt->_V().rows() == dimy + rgrlen + int(have_constant==true), "alternative is not compatible" ); 249 249 alter_est.set_parameters ( alt->_dimx(), alt->_V(), alt->_nu() ); 250 250 alter_est.validate(); … … 258 258 if ( eg ) { 259 259 bdm_assert ( eg->_dimx() == dimy, "prior is not compatible" ); 260 bdm_assert ( eg->_V().rows() == dimy + rgrlen , "prior is not compatible" );260 bdm_assert ( eg->_V().rows() == dimy + rgrlen + int(have_constant==true), "prior is not compatible" ); 261 261 est.set_parameters ( eg->_dimx(), eg->_V(), eg->_nu() ); 262 262 est.validate(); 263 263 } else { 264 est.set_parameters ( dimy, zeros ( dimy + rgrlen ) ); 265 est.validate(); 264 est.set_parameters ( dimy, zeros ( dimy + rgrlen +int(have_constant==true)) ); 266 265 set_prior_default ( est ); 267 266 } -
library/bdm/estim/arx.h
r979 r990 49 49 //! RV of regressor 50 50 RV rgr; 51 //! length of the regressor 51 //! length of the regressor (without optional constant) 52 52 int rgrlen; 53 53 //! posterior density … … 139 139 est.validate(); 140 140 //if dimc not set set it from V 141 if ( dimc == 0 ) { 142 dimc = posterior()._V().rows() - dimy - int ( have_constant == true ); 141 if(dimy>0) {//statistics is assigned 142 if (posterior()._V().rows()>dimy) {//statistics is assigned 143 rgrlen=posterior()._V().rows() - dimy - int ( have_constant == true ); 144 } 145 } else{ 146 bdm_error("No posterior or yrv assigned matrix assigned"); 143 147 } 144 145 if ( have_constant ) {146 dyad = ones ( dimy + dimc + 1 );147 } else {148 dyad = zeros ( dimy + dimc);148 dimc =rgrlen; 149 150 if(est._dimx()==0) { // no prior 151 est.set_parameters(dimy, zeros(dimy+rgrlen+int(have_constant==true))); 152 set_prior_default(est); 149 153 } 150 154 if (alter_est.dimension()==0) alter_est=est; 155 156 dyad = ones ( est._V().rows() ); 151 157 } 152 158 //! function sets prior and alternative density … … 194 200 195 201 void bayes ( const vec &val, const vec &cond ) { 196 int arx_cond_size=rgrlen -int(have_constant==true); 197 bdm_assert_debug(cond.size()>arx_cond_size, "ARXfrg: Insufficient conditioning, frg not given."); 198 frg = cond ( arx_cond_size ); // the first part after rgrlen 199 ARX::bayes ( val, cond.left(arx_cond_size) ); 202 bdm_assert_debug(cond.size()>rgrlen, "ARXfrg: Insufficient conditioning, frg not given."); 203 frg = cond ( rgrlen); // the first part after rgrlen 204 ARX::bayes ( val, cond.left(rgrlen) ); 200 205 } 201 206 void validate() {