Debian Codegraph @

tests/conditional_forecasts/3/fs2000_conditional_forecast_initval.mod

raw
1 /* Mod file tests the correctness of the conditional_forecast command when used together with initval by
2 * - checking whether the unconditional forecast from the conditional_forecast-command
3 * coincides with the one from the forecast command
4 * - checking whether the conditional forecast coincides with the path of
5 * capital derived when simulating the model with simult_ and the computed exogenous instruments
6 * - initval should not play a role as initial conditions need to be set with histval; with initval
7 * the subsequently computed steady state is used
8 */
9
10 var m P c e W R k d n l gy_obs gp_obs y dA;
11 varexo e_a e_m;
12
13 parameters alp bet gam mst rho psi del;
14
15 alp = 0.33;
16 bet = 0.99;
17 gam = 0.003;
18 mst = 1.011;
19 rho = 0.7;
20 psi = 0.787;
21 del = 0.02;
22
23 model;
24 dA = exp(gam+e_a);
25 log(m) = (1-rho)*log(mst) + rho*log(m(-1))+e_m;
26 -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;
27 W = l/n;
28 -(psi/(1-psi))*(c*P/(1-n))+l/n = 0;
29 R = P*(1-alp)*exp(-alp*(gam+e_a))*k(-1)^alp*n^(-alp)/W;
30 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;
31 c+k = exp(-alp*(gam+e_a))*k(-1)^alp*n^(1-alp)+(1-del)*exp(-(gam+e_a))*k(-1);
32 P*c = m;
33 m-1+d = l;
34 e = exp(e_a);
35 y = k(-1)^alp*n^(1-alp)*exp(-alp*(gam+e_a));
36 gy_obs = dA*y/y(-1);
37 gp_obs = (P/P(-1))*m(-1)/dA;
38 end;
39
40 initval;
41 k = 6;
42 m = mst;
43 P = 2.25;
44 c = 0.45;
45 e = 1;
46 W = 4;
47 R = 1.02;
48 d = 0.85;
49 n = 0.19;
50 l = 0.86;
51 y = 0.6;
52 gy_obs = exp(gam);
53 gp_obs = exp(-gam);
54 dA = exp(gam);
55 end;
56
57 shocks;
58 var e_a; stderr 0.014;
59 var e_m; stderr 0.005;
60 end;
61
62 steady(tolx=1e-10,tolf=1e-12);
63
64 check;
65
66 stoch_simul(irf=0,order=1);
67
68 conditional_forecast_paths;
69 var gy_obs;
70 periods 1 2 3:5;
71 values 0.01 -0.02 0;
72 var gp_obs;
73 periods 1 2 3:5;
74 values 1 1.04 0.98;
75 end;
76
77 %set capital to non-steady state value
78 initval;
79 k = 6;
80 end;
81
82 conditional_forecast(periods=100,parameter_set=calibration,replic=10000, controlled_varexo=(e_m,e_a));
83
84 plot_conditional_forecast(periods=100) gy_obs gp_obs k;
85 forecast(periods=100);
86
87 %compare unconditional forecasts
88 cond_forecast=oo_.conditional_forecast;
89 if max(abs(cond_forecast.uncond.Mean.k(2:end)-oo_.forecast.Mean.k))>1e-8
90 error('Unconditional Forecasts do not match')
91 end
92
93 %compare conditional forecasts; initval should not play a role as initial
94 %conditions need to be set with histval;
95 initial_condition_states = oo_.dr.ys;
96 shock_matrix = zeros(options_cond_fcst_.periods ,M_.exo_nbr); %create shock matrix with found controlled shocks
97 shock_matrix(1:5,strmatch('e_a',M_.exo_names,'exact')) = cond_forecast.controlled_exo_variables.Mean.e_a; %set controlled shocks to their values
98 shock_matrix(1:5,strmatch('e_m',M_.exo_names,'exact')) = cond_forecast.controlled_exo_variables.Mean.e_m; %set controlled shocks to their values
99
100 y_simult = simult_(M_,options_,initial_condition_states,oo_.dr,shock_matrix,1);
101
102 if max(abs(y_simult(strmatch('k',M_.endo_names,'exact'),:)'-cond_forecast.cond.Mean.k))>1e-8
103 error('Unconditional Forecasts do not match')
104 end