diff --git a/matlab/dyn_forecast.m b/matlab/dyn_forecast.m index 636a46eb143b6de10eb966797badbec9eecf6b26..ff943ebdaf941ae9d758755458679832b8ec61b6 100644 --- a/matlab/dyn_forecast.m +++ b/matlab/dyn_forecast.m @@ -1,7 +1,7 @@ -function [forecast,info] = 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) +% function forecast = dyn_forecast(var_list,M,options,oo,task,dataset_info) % 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 % var_list: list of variables (character matrix) @@ -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). % OUTPUTS -% nothing is returned but the procedure saves output -% in oo_.forecast.Mean -% oo_.forecast.HPDinf -% oo_.forecast.HPDsup -% +% forecast: structure containing fields +% Mean: point estimate +% HPDinf: lower bound of confidence band, ignoring +% 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 % none -% Copyright © 2003-2018 Dynare Team +% Copyright © 2003-2022 Dynare Team % % This file is part of Dynare. % @@ -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 % 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 error('The prefiltering option is not allowed without providing a dataset') elseif nargin==6 mean_varobs=dataset_info.descriptive.mean'; end -info = 0; - oo=make_ex_(M,options,oo); maximum_lag = M.maximum_lag; @@ -205,4 +213,4 @@ end if ~options.nograph oo.forecast = forecast; forecast_graphs(var_list, M, oo, options) -end +end \ No newline at end of file diff --git a/tests/smoother2histval/fs2000_smooth_ML.mod b/tests/smoother2histval/fs2000_smooth_ML.mod index 790aab1a75ffd676da5ce98845573f009c688780..990d6009521487e96d0ea3e03adaca45fc4c0e6f 100644 --- a/tests/smoother2histval/fs2000_smooth_ML.mod +++ b/tests/smoother2histval/fs2000_smooth_ML.mod @@ -90,7 +90,7 @@ smoother2histval; 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 error('Forecasts do not match')