Changeset ffb0c31 in tol
- Timestamp:
- Nov 13, 2009, 7:12:57 PM (17 years ago)
- Branches:
- 1941-docker-image-to-test, devel, master
- Children:
- de893de
- Parents:
- c255c99
- Location:
- tol/stdlib/math/stat/models/bayesian/bysMcmc
- Files:
-
- 2 edited
-
_config.tol (modified) (2 diffs)
-
bsr/gibbs/_arimaBlock.tol (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
tol/stdlib/math/stat/models/bayesian/bysMcmc/_config.tol
rc255c99 rffb0c31 138 138 //Arima filter method 139 139 Text bsr.arimaFilter = BysMcmc::Options::Arima.Filter::FastChol; 140 //Enables/disables storement of the Markov chain of initial values 141 Real bsr.arimaStoreInitialValues = False; 140 142 //=========================================================================== 141 143 //CODA and other diagnostic report configuration … … 188 190 //If true an internal TOL profiling will be executed 189 191 Real do.mcmc.profiler = False; 192 193 @BysInf.Report.Config GetReportConfig(Real void) 194 { 195 @BysInf.Report.Config 196 ( 197 report.raftery.diag.q, 198 report.raftery.diag.r, 199 report.raftery.diag.s, 200 report.raftery.diag.eps, 201 report.acf.lag, 202 report.histogram.parts, 203 report.kerDens.points 204 ) 205 }; 190 206 191 207 //////////////////////////////////////////////////////////////////////////// -
tol/stdlib/math/stat/models/bayesian/bysMcmc/bsr/gibbs/_arimaBlock.tol
rc255c99 rffb0c31 34 34 VMatrix _.difFilter = Rand(0,0,0,0); 35 35 Set _.segment.free.index = Copy(Empty); 36 VMatrix _.U0 = Rand(0,1,0,0); 37 Matrix _.U0.cache = Rand(0,0,0,0); 38 Matrix _.U0.mcmc = Rand(0,0,0,0); 39 Set _.U0.names = Copy(Empty); 36 40 37 41 //-------------------------------------------------------------------------- … … 86 90 Real numDifData = m; 87 91 VMatrix D = Eye(m); 92 VMatrix u0 = Rand(0,0,0,0); 88 93 Set segment->ArimaAuxInfo := 89 94 [[ 90 numPar, m, difDegree, p, q, numDifData, dif, ar, ma, D 95 numPar, m, difDegree, p, q, numDifData, dif, ar, ma, D, u0 91 96 ]]; 92 97 Real SetIndexByName(segment->ArimaAuxInfo); … … 191 196 Set Li_ar_factors = Copy(Empty); 192 197 Set L_ma_factors = Copy(Empty); 193 //WriteLn("TRACE"+_MID+" initializeArimaBlock["<<resBlockNum_+"] 2.2.7 "+Time); 198 VMatrix u0 = Rand(0,0,0,0); 199 WriteLn("TRACE"+_MID+" initializeArimaBlock 3 "); 200 Set If(_.config::bsr.arimaStoreInitialValues, 201 { 202 WriteLn("TRACE"+_MID+" initializeArimaBlock 4.1 p="<<p); 203 Set z0.names = For(1,p,Text(Real k) 204 { 205 Text name = segment->Name+".InitialValue.Noise."+IntText(k); 206 Eval(name+"=name") 207 }); 208 WriteLn("TRACE"+_MID+" initializeArimaBlock 4.2 q="<<q); 209 Set a0.names = For(1,q,Text(Real k) 210 { 211 Text name = segment->Name+".InitialValue.Residual."+IntText(k); 212 Eval(name+"=name") 213 }); 214 Set u0.names = z0.names<<a0.names; 215 WriteLn("TRACE"+_MID+" initializeArimaBlock after 4.3 u0.names=\n"<<u0.names); 216 Append(_.U0.names, u0.names, True) 217 }); 218 WriteLn("TRACE"+_MID+" initializeArimaBlock 5 "); 194 219 Set segment->ArimaAuxInfo := 195 220 [[ 196 221 numPar, m, difDegree, p, q, numDifData, 197 222 dif, ar, ma, Li_ar, L_ma ,Li_ar_factors, L_ma_factors, 198 D, equIdxVec 223 D, equIdxVec, u0 199 224 ]]; 200 225 Real SetIndexByName(segment->ArimaAuxInfo); … … 538 563 //WriteLn("TRACE"+_MID+" draw.scalar [iter "<<numSim+"] 1 "); 539 564 Matrix noise_ = VMat2Mat(noise); 565 Real oldResBlockNum = -1; 566 VMatrix If(_.config::bsr.arimaStoreInitialValues, 567 { 568 VMatrix _.U0 := Rand(0,1,0,0) 569 }); 540 570 Set arma.draw.all = 541 571 EvalSet(_.segment.free.index, Real arma.arms.draw(Real paramNum) … … 584 614 NameBlock almagro = ARMAProcess::Eval.Almagro(ar,ma,z_,sigma); 585 615 586 VMatrix u0 = almagro::Draw.U_cond_Z(0); 616 VMatrix u0 = If(oldResBlockNum == pd->resBlockNum, 617 { 618 aux::u0 619 }, 620 { 621 aux::u0 := almagro::Draw.U_cond_Z(0); 622 If(_.config::bsr.arimaStoreInitialValues, 623 { 624 _.U0 := _.U0 << aux::u0 625 }); 626 aux::u0 627 }); 587 628 VMatrix z0 = almagro::Get.Z0(u0); 588 629 VMatrix a0 = almagro::Get.A0(u0); … … 609 650 //WriteLn("TRACE"+_MID+" draw.scalar pd->coef="<<pd->coef); 610 651 pd->coef 652 }); 653 654 Matrix If(_.config::bsr.arimaStoreInitialValues, 655 { 656 Case( 657 numSim==1, 658 { 659 _.U0.mcmc := Rand(0,VRows(_.U0),0,0); 660 _.U0.cache := VMat2Mat(_.U0,True) 661 }, 662 numSim%100, 663 { 664 _.U0.cache := _.U0.cache << VMat2Mat(_.U0,True) 665 }, 666 1==1, 667 { 668 _.U0.mcmc := _.U0.mcmc << _.U0.cache; 669 _.U0.cache := Rand(0,VRows(_.U0),0,0) 670 }) 611 671 }); 612 672 //Real show.arma(0); … … 803 863 Set _.arimaStructBlock = 804 864 { 865 BysMcmc::@Config _.config := Copy(config); 866 805 867 //WriteLn("TRACESelecting noise with known wariance"); 806 868 Select(NoiseDistrib, Real(@BSR.NoiseDistrib segment)
Note: See TracChangeset
for help on using the changeset viewer.
