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

Merge branch 'forecast' into 'master'

:bug: forecast and smoothing: disallow unsupported options

See merge request !2317
parents 104f2fe8 b484b629
Branches
No related tags found
No related merge requests found
......@@ -54,6 +54,16 @@ elseif nargin==6
mean_varobs=dataset_info.descriptive.mean';
end
if options_.order>1 && M_.exo_det_nbr == 0
error('forecasting without varexo_det does not support order>1.')
end
if options_.order>2 && M_.exo_det_nbr > 0
error('forecasting with varexo_det does not support order>2.')
end
if options_.order==2 && options_.pruning
error('forecasting with varexo_det does not support pruning.')
end
oo_=make_ex_(M_,options_,oo_);
maximum_lag = M_.maximum_lag;
......@@ -152,9 +162,9 @@ end
if M_.exo_det_nbr == 0
if isequal(M_.H,0)
[yf,int_width] = forcst(oo_.dr,y0,horizon,var_list,M_,oo_,options_);
[yf,int_width] = forcst(oo_.dr,y0,horizon,var_list,M_,options_);
else
[yf,int_width,int_width_ME] = forcst(oo_.dr,y0,horizon,var_list,M_,oo_,options_);
[yf,int_width,int_width_ME] = forcst(oo_.dr,y0,horizon,var_list,M_,options_);
end
else
exo_det_length = size(oo_.exo_det_simul,1)-M_.maximum_lag;
......
......@@ -12,7 +12,7 @@ function dynare_estimation_1(var_list_,dname)
% SPECIAL REQUIREMENTS
% none
% Copyright © 2003-2023 Dynare Team
% Copyright © 2003-2024 Dynare Team
%
% This file is part of Dynare.
%
......@@ -582,12 +582,25 @@ if options_.particle.status
end
%Run and store classical smoother if needed
if (~((any(bayestopt_.pshape > 0) && options_.mh_replic) || (any(bayestopt_.pshape> 0) && options_.load_mh_file)) ...
|| ~options_.smoother ) && ~options_.partial_information % to be fixed
if options_.smoother && ... %Bayesian smoother requested before
(any(bayestopt_.pshape > 0) && options_.mh_replic || ... % Bayesian with MCMC run
any(bayestopt_.pshape > 0) && options_.load_mh_file) % Bayesian with loaded MCMC
% nothing to do
elseif options_.partial_information ||...
options_.order>1 %no particle smoother
% smoothing not yet supported
else
%% ML estimation, or posterior mode without Metropolis-Hastings or Metropolis without Bayesian smoothed variables
oo_=save_display_classical_smoother_results(xparam1,M_,oo_,options_,bayestopt_,dataset_,dataset_info,estim_params_);
end
if options_.forecast > 0 && options_.mh_replic == 0 && ~options_.load_mh_file
if options_.forecast == 0 || options_.mh_replic > 0 || options_.load_mh_file
% nothing to do
elseif options_.order>1 && M_.exo_det_nbr == 0 || ...
options_.order>2 && M_.exo_det_nbr > 0 || ...
options_.order==2 && options_.pruning
%forecasting not yet supported
else
oo_.forecast = dyn_forecast(var_list_,M_,options_,oo_,'smoother',dataset_info);
end
......
function [yf,int_width,int_width_ME]=forcst(dr,y0,horizon,var_list,M_,oo_,options_)
% function [yf,int_width,int_width_ME]=forecst(dr,y0,horizon,var_list,M_,oo_,options_)
function [yf,int_width,int_width_ME]=forcst(dr,y0,horizon,var_list,M_,options_)
% function [yf,int_width,int_width_ME]=forecst(dr,y0,horizon,var_list,M_,options_)
% computes mean forecast for a given value of the parameters
% computes also confidence band for the forecast
%
......@@ -10,7 +10,6 @@ function [yf,int_width,int_width_ME]=forcst(dr,y0,horizon,var_list,M_,oo_,option
% var_list: list of variables (character matrix)
% M_: Dynare model structure
% options_: Dynare options structure
% oo_: Dynare results structure
% OUTPUTS:
% yf: mean forecast
......@@ -22,7 +21,7 @@ function [yf,int_width,int_width_ME]=forcst(dr,y0,horizon,var_list,M_,oo_,option
% SPECIAL REQUIREMENTS
% none
% Copyright © 2003-2019 Dynare Team
% Copyright © 2003-2024 Dynare Team
%
% This file is part of Dynare.
%
......@@ -39,6 +38,10 @@ function [yf,int_width,int_width_ME]=forcst(dr,y0,horizon,var_list,M_,oo_,option
% You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <https://www.gnu.org/licenses/>.
if options_.order>1
error('forcst.m: Only order=1 is supported. Skipping computuations.')
end
yf = simult_(M_,options_,y0,dr,zeros(horizon,M_.exo_nbr),1);
nstatic = M_.nstatic;
nspred = M_.nspred;
......
function [y_,int_width,int_width_ME]=simultxdet(y0,ex,ex_det, iorder,var_list,M_,oo_,options_)
%function [y_,int_width]=simultxdet(y0,ex,ex_det, iorder,var_list,M_,oo_,options_)
%function [y_,int_width,int_width_ME]=simultxdet(y0,ex,ex_det, iorder,var_list,M_,oo_,options_)
%
% Simulates a stochastic model in the presence of deterministic exogenous shocks
%
......@@ -39,6 +39,11 @@ function [y_,int_width,int_width_ME]=simultxdet(y0,ex,ex_det, iorder,var_list,M_
% You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <https://www.gnu.org/licenses/>.
if options_.order>2
error('simultxdet.m: Forecasting with varexo_det does not support order>2.')
elseif options_.order==2 && options_.pruning
error('simultxdet.m: Forecasting with varexo_det does not support pruning.')
end
dr = oo_.dr;
ykmin = M_.maximum_lag;
endo_nbr = M_.endo_nbr;
......@@ -50,7 +55,6 @@ iter = size(ex,1);
if size(ex_det, 1) ~= iter+ykmin
error('Size mismatch: number of forecasting periods for stochastic exogenous and deterministic exogenous don''t match')
end
nx = size(dr.ghu,2);
y_ = zeros(size(y0,1),iter+ykmin);
y_(:,1:ykmin) = y0;
k1 = ykmin:-1:1;
......
......@@ -63,7 +63,7 @@ steady(tolx=1e-10,tolf=1e-12);
check;
stoch_simul(irf=0);
stoch_simul(irf=0,order=1);
conditional_forecast_paths;
var gy_obs;
......
......@@ -61,7 +61,7 @@ steady;
check;
stoch_simul(irf=0);
stoch_simul(irf=0,order=1);
conditional_forecast_paths;
var gy_obs;
......
......@@ -87,6 +87,6 @@ steady;
smoother2histval(period = 5);
options_.loglinear=0;
stoch_simul(nomoments);
stoch_simul(nomoments,order=1);
forecast;
......@@ -54,6 +54,6 @@ b(0) = 0.1;
a(0) = 0.3;
end;
stoch_simul(nograph, periods = 200);
stoch_simul(nograph, periods = 200,order=1);
forecast;
\ No newline at end of file
......@@ -49,7 +49,7 @@ a(-1) = 0.3;
u(-1) = 0.1;
end;
stoch_simul(nograph, periods = 200);
stoch_simul(nograph, periods = 200,order=1);
forecast;
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment