Debian Codegraph @

tests/deterministic_simulations/multiple_lead_lags/AR2.mod

raw
1 var y_backward;
2
3 parameters rho_1 rho_2;
4
5 rho_1=0.2;
6 rho_2=0.1;
7
8 // Equilibrium conditions
9 model;
10 y_backward=rho_1*y_backward(-1)+rho_2*y_backward(-2);
11 end;
12
13 // Set starting value for solver
14 initval;
15 y_backward=1;
16 end;
17 steady;
18
19 // Set initial conditions for state variables
20 histval;
21 y_backward(0)=1;
22 y_backward(-1)=2;
23 end;
24
25
26 // Check the Blanchard-Kahn conditions
27 check;
28
29 // Deterministic simulation of the model for 200 periods
30 perfect_foresight_setup(periods=100);
31 perfect_foresight_solver(tolf=1e-12);
32
33 if ~oo_.deterministic_simulation.status
34 error('Perfect foresight simulation failed')
35 end
36
37 // Display the path of consumption and capital
38 rplot y_backward;
39
40 junk=zeros(1,options_.periods+M_.maximum_lag);
41 junk(1)=2;
42 junk(2)=1;
43
44 for ii=3:options_.periods+2
45 junk(ii)=M_.params(strmatch('rho_1',M_.param_names,'exact'))*junk(ii-1)+M_.params(strmatch('rho_2',M_.param_names,'exact'))*junk(ii-2);
46 end
47
48 if max(abs(junk(M_.maximum_lag+1:end)-oo_.endo_simul(strmatch('y_backward',M_.endo_names,'exact'),:)))>1e-10
49 error('Solution of purely backwards model not correct')
50 end
51