| 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 |
periods 2; |
| 39 |
values 0.9; |
| 40 |
end; |
| 41 |
|
| 42 |
perfect_foresight_setup(periods=200); |
| 43 |
perfect_foresight_solver; |
| 44 |
|
| 45 |
reference = oo_.endo_simul; |
| 46 |
|
| 47 |
data1 = repmat([oo_.steady_state' 1], 4, 1); |
| 48 |
ds = dseries(data1, '1Y', [M_.endo_names; M_.exo_names]); |
| 49 |
|
| 50 |
histval_file(series = ds); |
| 51 |
perfect_foresight_setup(periods=200); |
| 52 |
perfect_foresight_solver; |
| 53 |
|
| 54 |
if ~oo_.deterministic_simulation.status |
| 55 |
error('Perfect foresight simulation failed'); |
| 56 |
end |
| 57 |
|
| 58 |
if max(max(abs(reference(1:5,5:end) - oo_.endo_simul(1:5,5:end)))) > 1e-8 |
| 59 |
error('Simulation with leads and lags doesn''t match the one with auxiliary variables') |
| 60 |
end |
| 61 |
|
| 62 |
data1 = repmat([oo_.steady_state' 1], 6, 1); |
| 63 |
ds1 = dseries(data1, '1Y', [M_.endo_names; M_.exo_names]); |
| 64 |
|
| 65 |
histval_file(series = ds1, first_obs = 3, last_obs = 6, nobs = 4); |
| 66 |
|
| 67 |
perfect_foresight_setup(periods=200); |
| 68 |
perfect_foresight_solver; |
| 69 |
|
| 70 |
if ~oo_.deterministic_simulation.status |
| 71 |
error('Perfect foresight simulation failed'); |
| 72 |
end |
| 73 |
|
| 74 |
if max(max(abs(reference(1:5,:) - oo_.endo_simul(1:5,:)))) > 1e-8 |
| 75 |
error('Simulation with leads and lags doesn''t match the one with auxiliary variables') |
| 76 |
end |