Skip to content
Snippets Groups Projects
Verified Commit 41294b3f authored by Sébastien Villemot's avatar Sébastien Villemot
Browse files

Merge branch 'occbin_forecast' of git.dynare.org:JohannesPfeifer/dynare

Ref. !2304
parents a13b2b57 56227c74
No related branches found
No related tags found
No related merge requests found
...@@ -18,7 +18,7 @@ function [forecast, error_flag] = forecast(options_,M_,dr,endo_steady_state,exo_ ...@@ -18,7 +18,7 @@ function [forecast, error_flag] = forecast(options_,M_,dr,endo_steady_state,exo_
% SPECIAL REQUIREMENTS % SPECIAL REQUIREMENTS
% none. % none.
% Copyright © 2022-2023 Dynare Team % Copyright © 2022-2024 Dynare Team
% %
% This file is part of Dynare. % This file is part of Dynare.
% %
...@@ -79,6 +79,7 @@ if ~isempty(shocks_input) ...@@ -79,6 +79,7 @@ if ~isempty(shocks_input)
end end
if opts.replic if opts.replic
options_.noprint=true;
h = dyn_waitbar(0,'Please wait occbin forecast replic ...'); h = dyn_waitbar(0,'Please wait occbin forecast replic ...');
ishock = find(sqrt(diag((M_.Sigma_e)))); ishock = find(sqrt(diag((M_.Sigma_e))));
options_.occbin.simul.exo_pos=ishock; options_.occbin.simul.exo_pos=ishock;
...@@ -98,7 +99,7 @@ if opts.replic ...@@ -98,7 +99,7 @@ if opts.replic
error_flag=true(opts.replic,1); error_flag=true(opts.replic,1);
simul_SHOCKS=NaN(forecast_horizon,M_.exo_nbr,opts.replic); simul_SHOCKS=NaN(forecast_horizon,M_.exo_nbr,opts.replic);
for iter=1:opts.replic for iter=1:opts.replic
options_.occbin.simul.SHOCKS = shocks_base+transpose(U*sqrt(S)*SHOCKS_add(:,:,iter)); options_.occbin.simul.SHOCKS = shocks_base(:,ishock)+transpose(U*sqrt(S)*SHOCKS_add(:,:,iter));
options_.occbin.simul.waitbar=0; options_.occbin.simul.waitbar=0;
[~, out] = occbin.solver(M_,options_,dr,endo_steady_state,exo_steady_state,exo_det_steady_state); [~, out] = occbin.solver(M_,options_,dr,endo_steady_state,exo_steady_state,exo_det_steady_state);
error_flag(iter)=out.error_flag; error_flag(iter)=out.error_flag;
...@@ -120,6 +121,9 @@ if opts.replic ...@@ -120,6 +121,9 @@ if opts.replic
save('Occbin_forecast_debug','simul_SHOCKS','z','iter','frcst_regime_history','error_flag') save('Occbin_forecast_debug','simul_SHOCKS','z','iter','frcst_regime_history','error_flag')
end end
inx=find(error_flag==0); inx=find(error_flag==0);
if length(inx)<opts.replic
fprintf('\noccbin.forecast: forecast simulation was only successful in %u of %u simulations.\n',length(inx),opts.replic);
end
z.linear=z.linear(:,:,inx); z.linear=z.linear(:,:,inx);
z.piecewise=z.piecewise(:,:,inx); z.piecewise=z.piecewise(:,:,inx);
z.min.piecewise = min(z.piecewise,[],3); z.min.piecewise = min(z.piecewise,[],3);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment