2022-04-21 17:09:27 +02:00
|
|
|
/* Tests perfect_foresight_with_expectation_errors_{setup,solver}
|
|
|
|
using the shocks(learnt_in=…) and endval(learnt_in=…) syntax */
|
|
|
|
|
|
|
|
var c k;
|
|
|
|
varexo x;
|
|
|
|
|
|
|
|
parameters alph gam delt bet aa;
|
|
|
|
alph=0.5;
|
|
|
|
gam=0.5;
|
|
|
|
delt=0.02;
|
|
|
|
bet=0.05;
|
|
|
|
aa=0.5;
|
|
|
|
|
|
|
|
|
|
|
|
model;
|
|
|
|
c + k - aa*x*k(-1)^alph - (1-delt)*k(-1);
|
|
|
|
c^(-gam) - (1+bet)^(-1)*(aa*alph*x(+1)*k^(alph-1) + 1 - delt)*c(+1)^(-gam);
|
|
|
|
end;
|
|
|
|
|
|
|
|
initval;
|
|
|
|
x = 1;
|
|
|
|
k = ((delt+bet)/(1.0*aa*alph))^(1/(alph-1));
|
|
|
|
c = aa*k^alph-delt*k;
|
|
|
|
end;
|
|
|
|
|
|
|
|
steady;
|
|
|
|
|
|
|
|
check;
|
|
|
|
|
2022-04-29 15:55:33 +02:00
|
|
|
shocks(learnt_in = 1);
|
2022-04-21 17:09:27 +02:00
|
|
|
var x;
|
2022-04-26 15:22:15 +02:00
|
|
|
periods 1:2;
|
2022-04-21 17:09:27 +02:00
|
|
|
values 1.2;
|
|
|
|
end;
|
|
|
|
|
|
|
|
shocks(learnt_in = 2);
|
|
|
|
var x;
|
|
|
|
periods 2;
|
2022-04-26 15:22:15 +02:00
|
|
|
add 0.1;
|
2022-04-21 17:09:27 +02:00
|
|
|
end;
|
|
|
|
|
|
|
|
endval(learnt_in = 2);
|
|
|
|
x = 1.1;
|
|
|
|
end;
|
|
|
|
|
|
|
|
shocks(learnt_in = 3);
|
|
|
|
var x;
|
2022-04-26 15:22:15 +02:00
|
|
|
periods 3 7;
|
|
|
|
values 1.4 1.5;
|
2022-04-21 17:09:27 +02:00
|
|
|
end;
|
|
|
|
|
|
|
|
endval(learnt_in = 3);
|
2022-05-03 17:46:59 +02:00
|
|
|
x += 0.1;
|
2022-04-21 17:09:27 +02:00
|
|
|
end;
|
|
|
|
|
|
|
|
// Dummy block, that will be overwritten by the next one
|
|
|
|
shocks(learnt_in = 6);
|
|
|
|
var x;
|
|
|
|
periods 6:8;
|
|
|
|
values 10;
|
|
|
|
end;
|
|
|
|
|
|
|
|
shocks(learnt_in = 6, overwrite);
|
|
|
|
var x;
|
|
|
|
periods 6:7;
|
2022-04-26 15:22:15 +02:00
|
|
|
multiply 0.8;
|
2022-04-21 17:09:27 +02:00
|
|
|
end;
|
|
|
|
|
|
|
|
endval(learnt_in = 6);
|
2022-05-03 17:46:59 +02:00
|
|
|
x *= 0.75;
|
2022-04-21 17:09:27 +02:00
|
|
|
end;
|
|
|
|
|
2023-06-15 16:59:37 +02:00
|
|
|
// Save initial steady state (it will be modified by pfwee)
|
|
|
|
orig_steady_state = oo_.steady_state;
|
|
|
|
orig_exo_steady_state = oo_.exo_steady_state;
|
|
|
|
|
2022-04-21 17:09:27 +02:00
|
|
|
perfect_foresight_with_expectation_errors_setup(periods = 7);
|
|
|
|
|
|
|
|
perfect_foresight_with_expectation_errors_solver;
|
2023-06-15 15:19:07 +02:00
|
|
|
pfwee_simul = oo_.endo_simul;
|
2022-04-21 17:09:27 +02:00
|
|
|
|
|
|
|
// Now compute the solution by hand to verify the results
|
2023-06-15 16:59:37 +02:00
|
|
|
oo_.steady_state = orig_steady_state;
|
|
|
|
oo_.exo_steady_state = orig_exo_steady_state;
|
2022-04-21 17:09:27 +02:00
|
|
|
|
|
|
|
perfect_foresight_setup;
|
|
|
|
|
2022-04-26 15:22:15 +02:00
|
|
|
// Information arriving in period 1 (temp shock now and tomorrow)
|
|
|
|
oo_.exo_simul(2:3,1) = 1.2;
|
2022-04-21 17:09:27 +02:00
|
|
|
perfect_foresight_solver;
|
|
|
|
|
|
|
|
// Information arriving in period 2 (temp shock now + permanent shock in future)
|
|
|
|
oo_.exo_simul(3,1) = 1.3;
|
|
|
|
oo_.exo_steady_state = 1.1;
|
|
|
|
oo_.exo_simul(end, 1) = oo_.exo_steady_state;
|
2023-06-07 17:18:18 +02:00
|
|
|
oo_.steady_state = evaluate_steady_state(oo_.steady_state, oo_.exo_steady_state, M_, options_, true);
|
2022-04-21 17:09:27 +02:00
|
|
|
oo_.endo_simul(:, end) = oo_.steady_state;
|
2023-01-16 16:14:28 +01:00
|
|
|
options_.periods = 6;
|
2022-04-21 17:09:27 +02:00
|
|
|
saved_endo = oo_.endo_simul(:, 1);
|
|
|
|
saved_exo = oo_.exo_simul(1, :);
|
|
|
|
oo_.endo_simul = oo_.endo_simul(:, 2:end);
|
|
|
|
oo_.exo_simul = oo_.exo_simul(2:end, :);
|
|
|
|
perfect_foresight_solver;
|
|
|
|
oo_.endo_simul = [ saved_endo oo_.endo_simul ];
|
|
|
|
oo_.exo_simul = [ saved_exo; oo_.exo_simul ];
|
|
|
|
|
2022-04-26 15:22:15 +02:00
|
|
|
// Information arriving in period 3 (temp shocks + permanent shock in future)
|
2022-04-21 17:09:27 +02:00
|
|
|
oo_.exo_simul(4,1) = 1.4;
|
2022-04-26 15:22:15 +02:00
|
|
|
oo_.exo_simul(8,1) = 1.5;
|
2022-05-03 17:46:59 +02:00
|
|
|
oo_.exo_steady_state = 1.1+0.1;
|
2022-04-21 17:09:27 +02:00
|
|
|
oo_.exo_simul(end, 1) = oo_.exo_steady_state;
|
2023-06-07 17:18:18 +02:00
|
|
|
oo_.steady_state = evaluate_steady_state(oo_.steady_state, oo_.exo_steady_state, M_, options_, true);
|
2022-04-21 17:09:27 +02:00
|
|
|
oo_.endo_simul(:, end) = oo_.steady_state;
|
2023-01-16 16:14:28 +01:00
|
|
|
options_.periods = 5;
|
2022-04-21 17:09:27 +02:00
|
|
|
saved_endo = oo_.endo_simul(:, 1:2);
|
|
|
|
saved_exo = oo_.exo_simul(1:2, :);
|
|
|
|
oo_.endo_simul = oo_.endo_simul(:, 3:end);
|
|
|
|
oo_.exo_simul = oo_.exo_simul(3:end, :);
|
|
|
|
perfect_foresight_solver;
|
|
|
|
oo_.endo_simul = [ saved_endo oo_.endo_simul ];
|
|
|
|
oo_.exo_simul = [ saved_exo; oo_.exo_simul ];
|
|
|
|
|
2022-04-26 15:22:15 +02:00
|
|
|
// Information arriving in period 6 (temp shocks + permanent shock)
|
|
|
|
oo_.exo_simul(7,1) = 1*0.8;
|
|
|
|
oo_.exo_simul(8,1) = 1.5*0.8;
|
2022-05-03 17:46:59 +02:00
|
|
|
oo_.exo_steady_state = (1.1+0.1)*0.75;
|
2022-04-21 17:09:27 +02:00
|
|
|
oo_.exo_simul(end, 1) = oo_.exo_steady_state;
|
2023-06-07 17:18:18 +02:00
|
|
|
oo_.steady_state = evaluate_steady_state(oo_.steady_state, oo_.exo_steady_state, M_, options_, true);
|
2022-04-21 17:09:27 +02:00
|
|
|
oo_.endo_simul(:, end) = oo_.steady_state;
|
2023-01-16 16:14:28 +01:00
|
|
|
options_.periods = 2;
|
2022-04-21 17:09:27 +02:00
|
|
|
saved_endo = oo_.endo_simul(:, 1:5);
|
|
|
|
saved_exo = oo_.exo_simul(1:5, :);
|
|
|
|
oo_.endo_simul = oo_.endo_simul(:, 6:end);
|
|
|
|
oo_.exo_simul = oo_.exo_simul(6:end, :);
|
|
|
|
perfect_foresight_solver;
|
|
|
|
oo_.endo_simul = [ saved_endo oo_.endo_simul ];
|
|
|
|
oo_.exo_simul = [ saved_exo; oo_.exo_simul ];
|
|
|
|
|
|
|
|
% We should have strict equality with first pfwee simulation, because algorithm
|
|
|
|
% and guess values are exactly the same.
|
2023-06-15 15:19:07 +02:00
|
|
|
if any(any(pfwee_simul-oo_.endo_simul ~= 0))
|
2022-04-21 17:09:27 +02:00
|
|
|
error('Error in perfect_foresight_with_expectation_errors')
|
|
|
|
end
|