Skip to content
Snippets Groups Projects
Commit 35a25b8f authored by Johannes Pfeifer's avatar Johannes Pfeifer
Browse files

dyn_forecast.m: gracefully exit if decision rules and remove unused output argument

parent 4195fa77
No related branches found
Tags
1 merge request!2051dyn_forecast: fix documentation and error handling
function [forecast,info] = dyn_forecast(var_list,M,options,oo,task,dataset_info) function forecast = dyn_forecast(var_list,M,options,oo,task,dataset_info)
% function dyn_forecast(var_list,M,options,oo,task,dataset_info) % function forecast = dyn_forecast(var_list,M,options,oo,task,dataset_info)
% computes mean forecast for a given value of the parameters % computes mean forecast for a given value of the parameters
% compues also confidence band for the forecast % computes also confidence bands for the forecast
% %
% INPUTS % INPUTS
% var_list: list of variables (character matrix) % var_list: list of variables (character matrix)
...@@ -13,15 +13,21 @@ function [forecast,info] = dyn_forecast(var_list,M,options,oo,task,dataset_info) ...@@ -13,15 +13,21 @@ function [forecast,info] = dyn_forecast(var_list,M,options,oo,task,dataset_info)
% dataset_info: Various informations about the dataset (descriptive statistics and missing observations). % dataset_info: Various informations about the dataset (descriptive statistics and missing observations).
% OUTPUTS % OUTPUTS
% nothing is returned but the procedure saves output % forecast: structure containing fields
% in oo_.forecast.Mean % Mean: point estimate
% oo_.forecast.HPDinf % HPDinf: lower bound of confidence band, ignoring
% oo_.forecast.HPDsup % measurement error
% % HPDsup: upper bound of confidence band, ignoring
% measurement error
% HPDinf_ME: lower bound of confidence band, accounting
% for measurement error
% HPDsup_ME: upper bound of confidence band, accounting
% for measurement error
% Exogenous: path for var_exo_det
% SPECIAL REQUIREMENTS % SPECIAL REQUIREMENTS
% none % none
% Copyright © 2003-2018 Dynare Team % Copyright © 2003-2022 Dynare Team
% %
% This file is part of Dynare. % This file is part of Dynare.
% %
...@@ -38,14 +44,16 @@ function [forecast,info] = dyn_forecast(var_list,M,options,oo,task,dataset_info) ...@@ -38,14 +44,16 @@ function [forecast,info] = dyn_forecast(var_list,M,options,oo,task,dataset_info)
% 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 ~isfield(oo,'dr') || isempty(oo.dr)
error('dyn_forecast: the decision rules have not been computed. Did you forget a stoch_simul-command?')
end
if nargin<6 && options.prefilter if nargin<6 && options.prefilter
error('The prefiltering option is not allowed without providing a dataset') error('The prefiltering option is not allowed without providing a dataset')
elseif nargin==6 elseif nargin==6
mean_varobs=dataset_info.descriptive.mean'; mean_varobs=dataset_info.descriptive.mean';
end end
info = 0;
oo=make_ex_(M,options,oo); oo=make_ex_(M,options,oo);
maximum_lag = M.maximum_lag; maximum_lag = M.maximum_lag;
......
...@@ -90,7 +90,7 @@ smoother2histval; ...@@ -90,7 +90,7 @@ smoother2histval;
forecast; forecast;
forecast_smoother2histval=oo_.forecast; forecast_smoother2histval=oo_.forecast;
[forecast_smoother,info] = dyn_forecast(var_list_,M_,options_,oo_,'smoother'); [forecast_smoother] = dyn_forecast(var_list_,M_,options_,oo_,'smoother');
if max(abs(struct2array(forecast_estimation.Mean)-struct2array(forecast_smoother2histval.Mean)))>1e-6 if max(abs(struct2array(forecast_estimation.Mean)-struct2array(forecast_smoother2histval.Mean)))>1e-6
error('Forecasts do not match') error('Forecasts do not match')
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment