perfect_foresight_with_expectation_errors_{setup,solver}: streamline handling of guess values
– Remove the terminal_steady_state_as_guess_value option to pfwee_solver – pfwee_setup now sets the same guess values as pf_setup (i.e. terminal steady state at all periods) – With constant_simulation_length option, pfwee_solver uses terminal steady state as guess values for periods that are added to the simulationremove-submodule
parent
30c17ad346
commit
c1b78e26ac
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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, :);
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 0de27e8dab9c4190be17ea8642cf301844c8043a
|
||||
Subproject commit a1b8602760e77895ee065de4dadb0d532c4e926e
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue