Skip to content
Snippets Groups Projects
Verified Commit 4aadc533 authored by Stéphane Adjemian's avatar Stéphane Adjemian
Browse files

Efficiency change. Update initial condition of SEP auxiliary model...

In each iteration using the solution from previous step. Previously
the initial guess for the auxiliary stochastic perfect forsight model
was the steady state in all periods and (future) worlds.
parent cea9a851
Branches
No related tags found
No related merge requests found
...@@ -68,23 +68,25 @@ while (t <= samplesize) ...@@ -68,23 +68,25 @@ while (t <= samplesize)
initialguess = []; initialguess = [];
end end
if t>2 if t>2
[endogenous_variables_paths(:,t), info_convergence, endogenousvariablespaths] = extended_path_core(innovations.positive_var_indx, ... [endogenous_variables_paths(:,t), info_convergence, endogenousvariablespaths, y] = extended_path_core(innovations.positive_var_indx, ...
spfm_exo_simul, ... spfm_exo_simul, ...
endogenous_variables_paths(:,t-1), ... endogenous_variables_paths(:,t-1), ...
pfm, ... pfm, ...
M_, ... M_, ...
options_, ... options_, ...
oo_, ... oo_, ...
initialguess); initialguess, ...
y);
else else
[endogenous_variables_paths(:,t), info_convergence, endogenousvariablespaths, pfm, options_] = extended_path_core(innovations.positive_var_indx, ... [endogenous_variables_paths(:,t), info_convergence, endogenousvariablespaths, y, pfm, options_] = extended_path_core(innovations.positive_var_indx, ...
spfm_exo_simul, ... spfm_exo_simul, ...
endogenous_variables_paths(:,t-1), ... endogenous_variables_paths(:,t-1), ...
pfm, ... pfm, ...
M_, ... M_, ...
options_, ... options_, ...
oo_, ... oo_, ...
initialguess); initialguess, ...
[]);
end end
if ~info_convergence if ~info_convergence
msg = sprintf('No convergence of the (stochastic) perfect foresight solver (in period %s)!', int2str(t)); msg = sprintf('No convergence of the (stochastic) perfect foresight solver (in period %s)!', int2str(t));
......
function [y, info_convergence, endogenousvariablespaths, pfm, options_] = extended_path_core(positive_var_indx, ... function [y1, info_convergence, endogenousvariablespaths, y, pfm, options_] = extended_path_core(positive_var_indx, ...
exo_simul, ... exo_simul, ...
initial_conditions ,... initial_conditions ,...
pfm, ... pfm, ...
M_, ... M_, ...
options_, ... options_, ...
oo_, ... oo_, ...
initialguess) initialguess, ...
y)
% Copyright © 2016-2025 Dynare Team % Copyright © 2016-2025 Dynare Team
% %
...@@ -41,7 +42,7 @@ stack_solve_algo = ep.stack_solve_algo; ...@@ -41,7 +42,7 @@ stack_solve_algo = ep.stack_solve_algo;
if init% Compute first order solution (Perturbation)... if init% Compute first order solution (Perturbation)...
endo_simul = simult_(M_,options_,initial_conditions,oo_.dr,exo_simul(2:end,:),1); endo_simul = simult_(M_,options_,initial_conditions,oo_.dr,exo_simul(2:end,:),1);
else else
if nargin==8 && ~isempty(initialguess) if nargin>7 && ~isempty(initialguess)
% Note that the first column of initialguess should be equal to initial_conditions. % Note that the first column of initialguess should be equal to initial_conditions.
endo_simul = initialguess; endo_simul = initialguess;
else else
...@@ -49,6 +50,10 @@ else ...@@ -49,6 +50,10 @@ else
end end
end end
if nargin~=9
y = [];
end
oo_.endo_simul = endo_simul; oo_.endo_simul = endo_simul;
if debug if debug
...@@ -77,17 +82,17 @@ else ...@@ -77,17 +82,17 @@ else
switch(algo) switch(algo)
case 0 case 0
% Full tree of future trajectories. % Full tree of future trajectories.
if nargout>3 if nargout>4
[flag, endogenousvariablespaths, errorcode, ~, pfm, options_] = solve_stochastic_perfect_foresight_model_0(endo_simul, exo_simul, options_, M_, pfm); [flag, endogenousvariablespaths, errorcode, y, pfm, options_] = solve_stochastic_perfect_foresight_model_0(endo_simul, exo_simul, y, options_, M_, pfm);
else else
[flag, endogenousvariablespaths, errorcode] = solve_stochastic_perfect_foresight_model_0(endo_simul, exo_simul, options_, M_, pfm); [flag, endogenousvariablespaths, errorcode, y] = solve_stochastic_perfect_foresight_model_0(endo_simul, exo_simul, y, options_, M_, pfm);
end end
case 1 case 1
% Sparse tree of future histories. % Sparse tree of future histories.
if nargout>3 if nargout>4
[flag, endogenousvariablespaths, errorcode, ~, pfm, options_] = solve_stochastic_perfect_foresight_model_1(endo_simul, exo_simul, options_, M_, pfm); [flag, endogenousvariablespaths, errorcode, y, pfm, options_] = solve_stochastic_perfect_foresight_model_1(endo_simul, exo_simul, y, options_, M_, pfm);
else else
[flag, endogenousvariablespaths, errorcode] = solve_stochastic_perfect_foresight_model_1(endo_simul, exo_simul, options_, M_, pfm); [flag, endogenousvariablespaths, errorcode, y] = solve_stochastic_perfect_foresight_model_1(endo_simul, exo_simul, y, options_, M_, pfm);
end end
end end
info_convergence = ~flag; info_convergence = ~flag;
...@@ -98,7 +103,7 @@ if ~info_convergence && ~options_.no_homotopy ...@@ -98,7 +103,7 @@ if ~info_convergence && ~options_.no_homotopy
end end
if info_convergence if info_convergence
y = endogenousvariablespaths(:,2); y1 = endogenousvariablespaths(:,2);
else else
y = NaN(size(endo_nbr,1)); y1 = NaN(size(endo_nbr,1));
end end
function [errorflag, endo_simul, errorcode, y, pfm, options_] = solve_stochastic_perfect_foresight_model_0(endo_simul, exo_simul, options_, M_, pfm) function [errorflag, endo_simul, errorcode, y, pfm, options_] = solve_stochastic_perfect_foresight_model_0(endo_simul, exo_simul, y, options_, M_, pfm)
% Copyright © 2025 Dynare Team % Copyright © 2025 Dynare Team
% %
...@@ -148,7 +148,9 @@ end ...@@ -148,7 +148,9 @@ end
pfm.Y = repmat(endo_simul(:),1,pfm.world_nbr); pfm.Y = repmat(endo_simul(:),1,pfm.world_nbr);
y = repmat(pfm.steady_state, pfm.dimension/pfm.ny, 1); if isempty(y)
y = repmat(pfm.steady_state, pfm.dimension/pfm.ny, 1);
end
if update_options_struct if update_options_struct
% Set algorithm % Set algorithm
......
function [errorflag, endo_simul, errorcode, y, pfm, options_] = solve_stochastic_perfect_foresight_model_1(endo_simul, exo_simul, options_, M_, pfm) function [errorflag, endo_simul, errorcode, y, pfm, options_] = solve_stochastic_perfect_foresight_model_1(endo_simul, exo_simul, y, options_, M_, pfm)
% Copyright © 2012-2025 Dynare Team % Copyright © 2012-2025 Dynare Team
% %
...@@ -113,7 +113,9 @@ if update_pfm_struct ...@@ -113,7 +113,9 @@ if update_pfm_struct
end end
y = repmat(pfm.steady_state, pfm.block_nbr, 1); if isempty(y)
y = repmat(pfm.steady_state, pfm.block_nbr, 1);
end
if update_options_struct if update_options_struct
% Set algorithm % Set algorithm
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment