Debian Codegraph @

tests/smoother2histval/fs2000_smooth_forecast.mod

raw
1 /* Test that the forecast command after smoother2histval gives the same result as the forecast
2 from the estimation command, and a forecast manually computed from the smoother output */
3 // Note that an observation equation has been modified in order to have an aux var for lagged endo
4
5 var m P c e W R k d n l gy_obs gp_obs y dA;
6 varexo e_a e_m;
7
8 parameters alp bet gam mst rho psi del;
9
10 alp = 0.33;
11 bet = 0.99;
12 gam = 0.003;
13 mst = 1.011;
14 rho = 0.7;
15 psi = 0.787;
16 del = 0.02;
17
18 model;
19 dA = exp(gam+e_a);
20 log(m) = (1-rho)*log(mst) + rho*log(m(-1))+e_m;
21 -P/(c(+1)*P(+1)*m)+bet*P(+1)*(alp*exp(-alp*(gam+log(e(+1))))*k^(alp-1)*n(+1)^(1-alp)+(1-del)*exp(-(gam+log(e(+1)))))/(c(+2)*P(+2)*m(+1))=0;
22 W = l/n;
23 -(psi/(1-psi))*(c*P/(1-n))+l/n = 0;
24 R = P*(1-alp)*exp(-alp*(gam+e_a))*k(-1)^alp*n^(-alp)/W;
25 1/(c*P)-bet*P*(1-alp)*exp(-alp*(gam+e_a))*k(-1)^alp*n^(1-alp)/(m*l*c(+1)*P(+1)) = 0;
26 c+k = exp(-alp*(gam+e_a))*k(-1)^alp*n^(1-alp)+(1-del)*exp(-(gam+e_a))*k(-1);
27 P*c = m;
28 m-1+d = l;
29 e = exp(e_a);
30 y = k(-1)^alp*n^(1-alp)*exp(-alp*(gam+e_a(-1)));
31 gy_obs = dA*y/y(-2);
32 gp_obs = (P/P(-1))*m(-1)/dA;
33 end;
34
35 steady_state_model;
36 dA = exp(gam);
37 gst = 1/dA;
38 m = mst;
39 khst = ( (1-gst*bet*(1-del)) / (alp*gst^alp*bet) )^(1/(alp-1));
40 xist = ( ((khst*gst)^alp - (1-gst*(1-del))*khst)/mst )^(-1);
41 nust = psi*mst^2/( (1-alp)*(1-psi)*bet*gst^alp*khst^alp );
42 n = xist/(nust+xist);
43 P = xist + nust;
44 k = khst*n;
45
46 l = psi*mst*n/( (1-psi)*(1-n) );
47 c = mst/P;
48 d = l - mst + 1;
49 y = k^alp*n^(1-alp)*gst^alp;
50 R = mst/bet;
51 W = l/n;
52 ist = y-c;
53 q = 1 - d;
54
55 e = 1;
56
57 gp_obs = m/dA;
58 gy_obs = dA;
59 end;
60
61 shocks;
62 var e_a; stderr 0.014;
63 var e_m; stderr 0.005;
64 end;
65
66 steady;
67
68 check;
69
70 estimated_params;
71 alp, beta_pdf, 0.356, 0.02;
72 bet, beta_pdf, 0.993, 0.002;
73 gam, normal_pdf, 0.0085, 0.003;
74 mst, normal_pdf, 1.0002, 0.007;
75 rho, beta_pdf, 0.129, 0.05;
76 psi, beta_pdf, 0.65, 0.05;
77 del, beta_pdf, 0.01, 0.005;
78 stderr e_a, inv_gamma_pdf, 0.035449, inf;
79 stderr e_m, inv_gamma_pdf, 0.008862, inf;
80 end;
81
82 varobs gp_obs gy_obs;
83
84 options_.solve_tolf = 1e-12;
85
86 estimation(order=1,datafile=fsdat_simul,silent_optimizer,mh_replic=0,mh_nblocks=1,mh_jscale=0.8,smoother,consider_all_endogenous,forecast=5);
87
88 forecast_estimation=oo_.forecast;
89
90 smoother2histval;
91
92 forecast;
93
94 forecast_smoother2histval=oo_.forecast;
95
96 forecast_smoother = forecasts.run(var_list_,M_,options_,oo_,'smoother');
97
98 if max(abs(struct2array(forecast_estimation.Mean)-struct2array(forecast_smoother2histval.Mean)))>1e-6
99 error('Forecasts do not match')
100 end
101
102 if max(abs(struct2array(forecast_estimation.Mean)-struct2array(forecast_smoother.Mean)))>1e-6
103 error('Forecasts do not match')
104 end