Changeset f9c7f71 in tol
- Timestamp:
- Apr 14, 2010, 3:51:56 PM (17 years ago)
- Branches:
- 1941-docker-image-to-test, devel, master
- Children:
- 823054d
- Parents:
- fdb5742
- File:
-
- 1 edited
-
tol_tests/tol/ARIMA/mcmc/mtrymh.mcmc.tol (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
tol_tests/tol/ARIMA/mcmc/mtrymh.mcmc.tol
rfdb5742 rf9c7f71 10 10 Matrix mcmc = Rand(0,mtm_arima::_.n,0,0); 11 11 12 Matrix L = { 13 Matrix COV = modEst.0::Correlations::COV; 14 Real n = mtm_arima::_.n; 15 Real r = Rows(COV); 16 Real k = r-n+1; 17 Choleski(Sub(COV,k,k,n,n)) 18 }; 19 Matrix Li = LTInverse(L); 20 VMatrix mtm_arima::_.L := Mat2VMat(L); 21 VMatrix mtm_arima::_.Li := Mat2VMat(Li); 22 Real mtm_arima::_.s := 1; 23 12 Real If(!ObjectExist("Matrix","modEst.0::Correlations::COV"), 13 { 14 Real mtm_arima::_.s := 0.001 15 }, 16 { 17 Matrix L = { 18 Matrix COV = modEst.0::Correlations::COV; 19 Real n = mtm_arima::_.n; 20 Real r = Rows(COV); 21 Real k = r-n+1; 22 Choleski(Sub(COV,k,k,n,n)) 23 }; 24 Matrix Li = LTInverse(L); 25 VMatrix mtm_arima::_.L := Mat2VMat(L); 26 VMatrix mtm_arima::_.Li := Mat2VMat(Li); 27 Real mtm_arima::_.s := 1 28 }); 29 24 30 25 31 Real numSim = 0; … … 43 49 44 50 /* */ 45 Real mtm_arima::_.sFactor := 1.0 0;51 Real mtm_arima::_.sFactor := 1.01; 46 52 Real numSim := 0; 47 53 Real mtm.t0 = Copy(Time); … … 62 68 Real raftery.rate = ?; 63 69 Real raftery.speed = ?; 70 Real burnin = 500; 64 71 65 72 Matrix cmp = mcmc | Group("ConcatColumns", For(1,Rows(PARAM),Matrix(Real j) … … 78 85 ]]}); 79 86 Real raftery.burnin := MatMax(SubCol(raftery,[[1]])); 87 Real burnin := Min(raftery.burnin,500); 80 88 Real raftery.thinning := MatMax(SubCol(raftery,[[4]])); 81 89 Real raftery.rate := (numSim-raftery.burnin)/(numSim*raftery.thinning); … … 83 91 ]]}); 84 92 93 Matrix mcmc.sub = SubRow(mcmc, Range(burnin+1,Rows(mcmc),1)); 94 Matrix x.avr = Tra(Constant(1,Rows(mcmc.sub),1/Rows(mcmc.sub))*mcmc.sub); 95 Set arima.avr = mtm_arima::col2arima(Mat2VMat(x.avr)); 96 Set ev.avr = ARIMALevinsonEval(arima.avr, Tra(SerMat(z))); 97 Serie e; 98 Serie residuals.avr = 99 { 100 Matrix res = ev.avr[4]; 101 Date ini = Succ(Last(z),Diario,-Rows(ev.avr[4])+1); 102 If(!Rows(res), 0*z, MatSerSet(Tra(res),Diario,ini)[1]) 103 }; 104 Real logLH.real = (SimulArima::EvalRealARIMA::ev)[12]; 105 Real logLH.avr = (ev.avr)[12]; 106 Real prob.refuse = Min(1,Max(0,1-Exp(logLH.avr-logLH.real))); 107 108 Real Q_draw_by_Pi_draw = mtm_arima::_.num_Q_draw/mtm_arima::_.num_draw; 109 Real num_logWeight_by_Pi_draw = mtm_arima::_.num_logWeight/mtm_arima::_.num_draw; 110 85 111 Text report = "" 86 112 <<rndSeed+"\t" … … 89 115 <<mtm_arima::_.n+"\t" 90 116 <<mtm_arima::_.k+"\t" 117 <<Q_draw_by_Pi_draw+"\t" 118 <<num_logWeight_by_Pi_draw+"\t" 91 119 <<arima.time+"\t" 92 120 <<mtm.time+"\t" … … 97 125 <<raftery.rate+"\t" 98 126 <<raftery.speed+"\t" 127 <<logLH.real+"\t" 128 <<logLH.avr+"\t" 129 <<prob.refuse+"\t" 99 130 <<numErr+"\t" 100 131 <<numWar+"\n"; … … 105 136 +"mtm_arima::_.n\t" 106 137 +"mtm_arima::_.k\t" 138 +"Q_draw_by_Pi_draw\t" 139 +"num_logWeight_by_Pi_draw\t" 107 140 +"arima.time\t" 108 141 +"mtm.time\t" … … 112 145 +"raftery.thinning\t" 113 146 +"raftery.rate\t" 114 +"raftery.speed\t" 147 +"logLH.real\t" 148 +"logLH.avr\t" 149 +"prob.refuse\t" 115 150 +"numErr\t" 116 151 +"numWar\n"));
Note: See TracChangeset
for help on using the changeset viewer.
