| 1 |
// Uses autonomous system from sim_base.mod, but adds separate system where exogenous variables have several leads and lags |
| 2 |
// Lags and leads on exogenous variables are substituted out by auxiliary variables |
| 3 |
|
| 4 |
var c cmav k z_backward z_forward; |
| 5 |
varexo x; |
| 6 |
|
| 7 |
parameters alph gam delt bet aa; |
| 8 |
alph=0.5; |
| 9 |
gam=0.5; |
| 10 |
delt=0.02; |
| 11 |
bet=0.05; |
| 12 |
aa=0.5; |
| 13 |
|
| 14 |
model; |
| 15 |
c + k - aa*x*k(-1)^alph - (1-delt)*k(-1); |
| 16 |
c^(-gam) - (1+bet)^(-1)*(aa*alph*x(+1)*k^(alph-1) + 1 - delt)*c(+1)^(-gam); |
| 17 |
z_backward=0.1*1+0.9*z_backward(-1) + (x(-4) - 1); |
| 18 |
z_forward=0.2*1+0.8*z_forward(+1) + (x(+4) - 1); |
| 19 |
cmav = 0.2*(c(-2) + c(-1) + c + c(+1) + c(+2)); |
| 20 |
end; |
| 21 |
|
| 22 |
initval; |
| 23 |
x = 1; |
| 24 |
end; |
| 25 |
|
| 26 |
steady_state_model; |
| 27 |
k = ((bet + delt)/(aa*alph*x))^(1/(alph - 1)); |
| 28 |
c = aa*x*k^alph - delt*k; |
| 29 |
z_backward = x; |
| 30 |
z_forward = x; |
| 31 |
cmav = c; |
| 32 |
end; |
| 33 |
|
| 34 |
steady; |
| 35 |
|
| 36 |
shocks; |
| 37 |
var x; |
| 38 |
stderr 0.01; |
| 39 |
end; |
| 40 |
|
| 41 |
s = rng; |
| 42 |
stoch_simul(periods=20, drop=0, irf=0); |
| 43 |
|
| 44 |
reference = oo_.endo_simul; |
| 45 |
|
| 46 |
data1 = repmat([oo_.steady_state' 1], 4, 1); |
| 47 |
ds = dseries(data1, '1Y', [M_.endo_names; M_.exo_names]); |
| 48 |
|
| 49 |
histval_file(series = ds); |
| 50 |
|
| 51 |
rng(s); |
| 52 |
stoch_simul(periods=20, drop=0, irf=0); |
| 53 |
|
| 54 |
if max(max(abs(reference(1:5,5:end) - oo_.endo_simul(1:5,5:end)))) > 1e-8 |
| 55 |
error('Simulation with leads and lags doesn''t match the reference') |
| 56 |
end |
| 57 |
|
| 58 |
data1 = repmat([oo_.steady_state' 1], 6, 1); |
| 59 |
ds1 = dseries(data1, '1Y', [M_.endo_names; M_.exo_names]); |
| 60 |
|
| 61 |
histval_file(series = ds1, first_obs = 6, last_obs = 6, nobs = 1); |
| 62 |
|
| 63 |
rng(s); |
| 64 |
stoch_simul(periods=20, drop=0, irf=0); |
| 65 |
|
| 66 |
if max(max(abs(reference(1:5,:) - oo_.endo_simul(1:5,:)))) > 1e-8 |
| 67 |
error('Simulation with leads and lags doesn''t match the reference') |
| 68 |
end |
| 69 |
|
| 70 |
histval_file(series = ds1, first_simulation_period = 7); |
| 71 |
|
| 72 |
rng(s); |
| 73 |
stoch_simul(periods=20, drop=0, irf=0); |
| 74 |
|
| 75 |
if max(max(abs(reference(1:5,:) - oo_.endo_simul(1:5,:)))) > 1e-8 |
| 76 |
error('Simulation with leads and lags doesn''t match the reference') |
| 77 |
end |
| 78 |
|
| 79 |
histval_file(series = ds1, first_simulation_period = 7Y); |
| 80 |
|
| 81 |
rng(s); |
| 82 |
stoch_simul(periods=20, drop=0, irf=0); |
| 83 |
|
| 84 |
if max(max(abs(reference(1:5,:) - oo_.endo_simul(1:5,:)))) > 1e-8 |
| 85 |
error('Simulation with leads and lags doesn''t match the reference') |
| 86 |
end |