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