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

mr#2067
Johannes Pfeifer 2022-07-01 09:44:43 +02:00
parent 4195fa779d
commit 35a25b8fb5
2 changed files with 21 additions and 13 deletions

View File

@ -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

View File

@ -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')