diff --git a/doc/manual/source/the-model-file.rst b/doc/manual/source/the-model-file.rst index 3665099488971110612492a35980ba82e619474a..e0dba00862cd7a917b9d563605f788425b08bad5 100644 --- a/doc/manual/source/the-model-file.rst +++ b/doc/manual/source/the-model-file.rst @@ -4174,16 +4174,7 @@ and ``endval`` blocks which are given a special ``learnt_in`` option. *Options* This command accepts all the options of :comm:`perfect_foresight_solver`, - with the same semantics, plus the following ones: - - .. option:: terminal_steady_state_as_guess_value - - By default, the initial guess for the computation of the path of - endogenous is the initial steady state (when using the information set - from period 1) or the previously simulated path (when using an - information set that is different from that of period 1). When this - option is given, the initial guess is instead the terminal steady - state. + with the same semantics, plus the following one: .. option:: constant_simulation_length diff --git a/matlab/default_option_values.m b/matlab/default_option_values.m index 2d3f6995df4379b2b7c65300200d0966f033ce27..52bd5b6feabaa16b42e4b1c8c85b26c6abb7810d 100644 --- a/matlab/default_option_values.m +++ b/matlab/default_option_values.m @@ -329,7 +329,6 @@ options_.no_homotopy = false; options_.homotopy_alt_starting_point = false; % Perfect foresight with expectation errors -options_.pfwee.terminal_steady_state_as_guess_value = false; options_.pfwee.constant_simulation_length = false; % Solution 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 a50fa6c017206f05970084527885631896eea79c..2a89e13efe5846e7c63bfcdc40e0aa8929cd2d6a 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 @@ -142,12 +142,12 @@ end % 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)]; + oo_.endo_simul = repmat(oo_.steady_state, 1, M_.maximum_lag+periods+M_.maximum_lead); else - oo_.endo_simul = [repmat(ys0_, 1, M_.maximum_lag) NaN(M_.endo_nbr, periods+M_.maximum_lead)]; + oo_.endo_simul = [repmat(ys0_, 1, M_.maximum_lag) repmat(oo_.steady_state, 1, periods+M_.maximum_lead)]; end if isempty(ex0_) - oo_.exo_simul = [repmat(oo_.exo_steady_state',M_.maximum_lag,1); NaN(periods+M_.maximum_lead,M_.exo_nbr)]; + oo_.exo_simul = repmat(oo_.exo_steady_state', M_.maximum_lag+periods+M_.maximum_lead, 1); else - oo_.exo_simul = [repmat(ex0_',M_.maximum_lag,1); NaN(periods+M_.maximum_lead,M_.exo_nbr)]; + oo_.exo_simul = [repmat(ex0_', M_.maximum_lag, 1); repmat(oo_.exo_steady_state', periods+M_.maximum_lead, 1)]; end 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 0e9cd3f26c44c8a3364becdc3cf84c32f1cc67a2..77b882b2e1c2789ad669ce543bf4a5c318609a06 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 @@ -55,15 +55,9 @@ while info_period <= periods else sim_length = periods - info_period + 1; end - if options_.pfwee.terminal_steady_state_as_guess_value - % Overwrite guess value with terminal steady state - oo_.endo_simul(:, M_.maximum_lag+(1:sim_length)) = repmat(oo_.steady_state, 1, sim_length); - elseif info_period == 1 - % Use initial steady state as guess value for first simulation if not using terminal steady state - oo_.endo_simul(:, M_.maximum_lag+(1:periods)) = repmat(initial_steady_state, 1, periods); - elseif options_.pfwee.constant_simulation_length && increment > M_.maximum_lead - % Use initial steady state as guess value for simulation periods that don’t yet have an initial guess (i.e. are NaNs) - oo_.endo_simul(:, M_.maximum_lag+periods-(0:increment-M_.maximum_lead-1)) = repmat(initial_steady_state, 1, increment-M_.maximum_lead); + if options_.pfwee.constant_simulation_length && increment > M_.maximum_lead + % Use terminal steady state as guess value for simulation periods that don’t yet have an initial guess (i.e. are NaNs at this point) + oo_.endo_simul(:, M_.maximum_lag+periods-(0:increment-M_.maximum_lead-1)) = repmat(oo_.steady_state, 1, increment-M_.maximum_lead); end oo_.endo_simul(:, end-M_.maximum_lead+1:end) = repmat(oo_.steady_state, 1, M_.maximum_lead); oo_.exo_simul = exo_simul(info_period:end, :); diff --git a/preprocessor b/preprocessor index 0de27e8dab9c4190be17ea8642cf301844c8043a..a1b8602760e77895ee065de4dadb0d532c4e926e 160000 --- a/preprocessor +++ b/preprocessor @@ -1 +1 @@ -Subproject commit 0de27e8dab9c4190be17ea8642cf301844c8043a +Subproject commit a1b8602760e77895ee065de4dadb0d532c4e926e diff --git a/tests/deterministic_simulations/pfwee.mod b/tests/deterministic_simulations/pfwee.mod index dcca363109d598c76eae8519b212782f35d72f50..a42300cbbc53ab6dc985829df297730953e338be 100644 --- a/tests/deterministic_simulations/pfwee.mod +++ b/tests/deterministic_simulations/pfwee.mod @@ -31,11 +31,7 @@ perfect_foresight_with_expectation_errors_setup(periods = 7, datafile = 'pfwee.c // First simulation with default options perfect_foresight_with_expectation_errors_solver; -pfwee1 = oo_.endo_simul; - -// Second simulation with alternative guess values -perfect_foresight_with_expectation_errors_solver(terminal_steady_state_as_guess_value); -pfwee2 = oo_.endo_simul; +pfwee_simul = oo_.endo_simul; // Now compute the solution by hand to verify the results @@ -93,12 +89,6 @@ 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. -if any(any(pfwee1-oo_.endo_simul ~= 0)) +if any(any(pfwee_simul-oo_.endo_simul ~= 0)) error('Error in perfect_foresight_with_expectation_errors') end - -% For the 2nd simulation, since the guess values are different, there are some -% numerical differences -if max(max(abs(pfwee2-oo_.endo_simul))) > 10*options_.dynatol.f - error('Error in perfect_foresight_with_expectation_errors + terminal_steady_state_as_guess_value') -end diff --git a/tests/deterministic_simulations/pfwee_constant_sim_length.mod b/tests/deterministic_simulations/pfwee_constant_sim_length.mod index d8a9e0bdeb86a3d343d64e522947d7a4c9dd6be5..82a5199452bd9ad9b247aca182089ca47f9a4954 100644 --- a/tests/deterministic_simulations/pfwee_constant_sim_length.mod +++ b/tests/deterministic_simulations/pfwee_constant_sim_length.mod @@ -29,12 +29,7 @@ check; // First simulation with default options perfect_foresight_with_expectation_errors_setup(periods = 7, datafile = 'pfwee.csv'); perfect_foresight_with_expectation_errors_solver(constant_simulation_length); -pfwee1 = oo_.endo_simul; - -// Second simulation with alternative guess values -perfect_foresight_with_expectation_errors_setup(periods = 7, datafile = 'pfwee.csv'); -perfect_foresight_with_expectation_errors_solver(terminal_steady_state_as_guess_value, constant_simulation_length); -pfwee2 = oo_.endo_simul; +pfwee_simul = oo_.endo_simul; // Now compute the solution by hand to verify the results @@ -80,8 +75,7 @@ oo_.exo_simul(8,1) = 1.1; oo_.exo_steady_state = 1.1; oo_.exo_simul(9:14, 1) = repmat(oo_.exo_steady_state', 6, 1); oo_.steady_state = evaluate_steady_state(oo_.steady_state, oo_.exo_steady_state, M_, options_, true); -oo_.endo_simul(:, 12:13) = repmat(initial_steady_state, 1, 2); -oo_.endo_simul(:, 14) = oo_.steady_state; +oo_.endo_simul(:, 12:14) = repmat(oo_.steady_state, 1, 3); saved_endo = oo_.endo_simul(:, 1:5); saved_exo = oo_.exo_simul(1:5, :); oo_.endo_simul = oo_.endo_simul(:, 6:end); @@ -92,12 +86,6 @@ 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. -if any(any(pfwee1-oo_.endo_simul ~= 0)) +if any(any(pfwee_simul-oo_.endo_simul ~= 0)) error('Error in perfect_foresight_with_expectation_errors') end - -% For the 2nd simulation, since the guess values are different, there are some -% numerical differences -if max(max(abs(pfwee2-oo_.endo_simul))) > 40*options_.dynatol.f - error('Error in perfect_foresight_with_expectation_errors + terminal_steady_state_as_guess_value') -end diff --git a/tests/deterministic_simulations/pfwee_learnt_in.mod b/tests/deterministic_simulations/pfwee_learnt_in.mod index 4d3dd438045d2125128ab22b2cc6a90a37354c92..8c2a0dc148b94073c73e78227809d7699b9a0706 100644 --- a/tests/deterministic_simulations/pfwee_learnt_in.mod +++ b/tests/deterministic_simulations/pfwee_learnt_in.mod @@ -74,11 +74,7 @@ perfect_foresight_with_expectation_errors_setup(periods = 7); // First simulation with default options perfect_foresight_with_expectation_errors_solver; -pfwee1 = oo_.endo_simul; - -// Second simulation with alternative guess values -perfect_foresight_with_expectation_errors_solver(terminal_steady_state_as_guess_value); -pfwee2 = oo_.endo_simul; +pfwee_simul = oo_.endo_simul; // Now compute the solution by hand to verify the results @@ -137,12 +133,6 @@ 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. -if any(any(pfwee1-oo_.endo_simul ~= 0)) +if any(any(pfwee_simul-oo_.endo_simul ~= 0)) error('Error in perfect_foresight_with_expectation_errors') end - -% For the 2nd simulation, since the guess values are different, there are some -% numerical differences -if max(max(abs(pfwee2-oo_.endo_simul))) > 10*options_.dynatol.f - error('Error in perfect_foresight_with_expectation_errors + terminal_steady_state_as_guess_value') -end