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