From b084c2e9317357c3557a80533f2f2083987c2187 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Villemot?= Date: Fri, 29 Apr 2022 15:49:59 +0200 Subject: [PATCH] Perfect foresight with expectation errors: move computation of terminal steady states to the setup command This is more logical, since those values are constraints from the point of view of the solver. Also, this allows to have maxit and tolf options for the steady state solver, at the level of the setup command, without a clash with the same option names for the deterministic solver at the level of the solver command. --- ...t_foresight_with_expectation_errors_setup.m | 18 ++++++++++++++++++ ..._foresight_with_expectation_errors_solver.m | 3 +-- preprocessor | 2 +- 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/matlab/perfect-foresight-models/perfect_foresight_with_expectation_errors_setup.m b/matlab/perfect-foresight-models/perfect_foresight_with_expectation_errors_setup.m index c4273c357..4664d627d 100644 --- a/matlab/perfect-foresight-models/perfect_foresight_with_expectation_errors_setup.m +++ b/matlab/perfect-foresight-models/perfect_foresight_with_expectation_errors_setup.m @@ -115,6 +115,24 @@ else end end +%% Compute the terminal steady state for all informational periods +oo_.pfwee.terminal_steady_state = NaN(M_.endo_nbr, periods); +orig_exo_steady_state = oo_.exo_steady_state; +for p = 1:periods + if p > 1 && all(oo_.pfwee.terminal_info(:, p) == oo_.pfwee.terminal_info(:, p-1)) + oo_.pfwee.terminal_steady_state(:, p) = oo_.pfwee.terminal_steady_state(:, p-1); + else + if p == 1 + init = oo_.steady_state; + else + init = oo_.pfwee.terminal_steady_state(:, p-1); + end + oo_.exo_steady_state = oo_.pfwee.terminal_info(:, p); + oo_.pfwee.terminal_steady_state(:, p) = evaluate_steady_state(init, M_, options_, oo_, true); + end +end +oo_.exo_steady_state = orig_exo_steady_state; + % Build initial paths for endos and exos (only initial conditions are set, the rest is NaN) if isempty(ys0_) oo_.endo_simul = [repmat(oo_.steady_state, 1, M_.maximum_lag) NaN(M_.endo_nbr, periods+M_.maximum_lead)]; diff --git a/matlab/perfect-foresight-models/perfect_foresight_with_expectation_errors_solver.m b/matlab/perfect-foresight-models/perfect_foresight_with_expectation_errors_solver.m index 8deee7efb..fdbdda3ce 100644 --- a/matlab/perfect-foresight-models/perfect_foresight_with_expectation_errors_solver.m +++ b/matlab/perfect-foresight-models/perfect_foresight_with_expectation_errors_solver.m @@ -42,8 +42,7 @@ end while info_period <= periods % Compute terminal steady state as anticipated oo_.exo_steady_state = oo_.pfwee.terminal_info(:, info_period); - steady_state_prev = oo_.steady_state; - [oo_.steady_state,~,info] = evaluate_steady_state(steady_state_prev, M_, options_, oo_, true); + oo_.steady_state = oo_.pfwee.terminal_steady_state(:, info_period); if options_.pfwee.constant_simulation_length && increment > 0 endo_simul = [ endo_simul NaN(M_.endo_nbr, increment)]; diff --git a/preprocessor b/preprocessor index 6509bc7d3..32761173e 160000 --- a/preprocessor +++ b/preprocessor @@ -1 +1 @@ -Subproject commit 6509bc7d3651d7b82adbf4ca53042dbefe6fe7fb +Subproject commit 32761173e00e7e40932341de36507707c16a9311