Skip to content
Snippets Groups Projects
Verified Commit f14d2ea4 authored by Johannes Pfeifer's avatar Johannes Pfeifer Committed by Sébastien Villemot
Browse files

:bug: forecast and smoothing: disallow unsupported options

(cherry picked from commit db286c1a)
parent 765a6b84
Branches
Tags
No related merge requests found
...@@ -54,6 +54,16 @@ elseif nargin==6 ...@@ -54,6 +54,16 @@ elseif nargin==6
mean_varobs=dataset_info.descriptive.mean'; mean_varobs=dataset_info.descriptive.mean';
end 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_); oo_=make_ex_(M_,options_,oo_);
maximum_lag = M_.maximum_lag; maximum_lag = M_.maximum_lag;
......
...@@ -12,7 +12,7 @@ function dynare_estimation_1(var_list_,dname) ...@@ -12,7 +12,7 @@ function dynare_estimation_1(var_list_,dname)
% SPECIAL REQUIREMENTS % SPECIAL REQUIREMENTS
% none % none
% Copyright © 2003-2023 Dynare Team % Copyright © 2003-2024 Dynare Team
% %
% This file is part of Dynare. % This file is part of Dynare.
% %
...@@ -570,12 +570,25 @@ if options_.particle.status ...@@ -570,12 +570,25 @@ if options_.particle.status
end end
%Run and store classical smoother if needed %Run and store classical smoother if needed
if (~((any(bayestopt_.pshape > 0) && options_.mh_replic) || (any(bayestopt_.pshape> 0) && options_.load_mh_file)) ... if options_.smoother && ... %Bayesian smoother requested before
|| ~options_.smoother ) && ~options_.partial_information % to be fixed (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 %% 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_); oo_=save_display_classical_smoother_results(xparam1,M_,oo_,options_,bayestopt_,dataset_,dataset_info,estim_params_);
end 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); oo_.forecast = dyn_forecast(var_list_,M_,options_,oo_,'smoother',dataset_info);
end end
......
...@@ -22,7 +22,7 @@ function [yf,int_width,int_width_ME]=forcst(dr,y0,horizon,var_list,M_,oo_,option ...@@ -22,7 +22,7 @@ function [yf,int_width,int_width_ME]=forcst(dr,y0,horizon,var_list,M_,oo_,option
% SPECIAL REQUIREMENTS % SPECIAL REQUIREMENTS
% none % none
% Copyright © 2003-2019 Dynare Team % Copyright © 2003-2024 Dynare Team
% %
% This file is part of Dynare. % This file is part of Dynare.
% %
...@@ -39,6 +39,10 @@ function [yf,int_width,int_width_ME]=forcst(dr,y0,horizon,var_list,M_,oo_,option ...@@ -39,6 +39,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 % You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <https://www.gnu.org/licenses/>. % 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); yf = simult_(M_,options_,y0,dr,zeros(horizon,M_.exo_nbr),1);
nstatic = M_.nstatic; nstatic = M_.nstatic;
nspred = M_.nspred; 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,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 % 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_ ...@@ -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 % You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <https://www.gnu.org/licenses/>. % 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; dr = oo_.dr;
ykmin = M_.maximum_lag; ykmin = M_.maximum_lag;
endo_nbr = M_.endo_nbr; endo_nbr = M_.endo_nbr;
...@@ -50,7 +55,6 @@ iter = size(ex,1); ...@@ -50,7 +55,6 @@ iter = size(ex,1);
if size(ex_det, 1) ~= iter+ykmin if size(ex_det, 1) ~= iter+ykmin
error('Size mismatch: number of forecasting periods for stochastic exogenous and deterministic exogenous don''t match') error('Size mismatch: number of forecasting periods for stochastic exogenous and deterministic exogenous don''t match')
end end
nx = size(dr.ghu,2);
y_ = zeros(size(y0,1),iter+ykmin); y_ = zeros(size(y0,1),iter+ykmin);
y_(:,1:ykmin) = y0; y_(:,1:ykmin) = y0;
k1 = ykmin:-1:1; k1 = ykmin:-1:1;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment