diff --git a/matlab/+occbin/DSGE_smoother.m b/matlab/+occbin/DSGE_smoother.m index ead33b243dacb846b1461a28c8b07251709deda2..656e84a3ce6fbb9e455208997f26e836d9700971 100644 --- a/matlab/+occbin/DSGE_smoother.m +++ b/matlab/+occbin/DSGE_smoother.m @@ -147,7 +147,7 @@ options_.noprint = true; if out.error_flag fprintf('Occbin smoother:: simulation within smoother did not converge.\n') print_info(out.error_flag, options_.noprint, options_) - oo_.occbin.smoother.error_flag=1; + oo_.occbin.smoother.error_flag=321; return; end regime_history = out.regime_history; @@ -213,7 +213,7 @@ while is_changed && maxiter>iter && ~is_periodic if out.error_flag fprintf('Occbin smoother:: simulation within smoother did not converge.\n') print_info(out.error_flag, false, options_) - oo_.occbin.smoother.error_flag=1; + oo_.occbin.smoother.error_flag=321; return; end regime_history = out.regime_history; @@ -363,7 +363,7 @@ if (maxiter==iter && is_changed) || is_periodic else fprintf('occbin.DSGE_smoother: The respective fields in oo_ will be left empty.\n') oo_.occbin.smoother=[]; - oo_.occbin.smoother.error_flag=1; + oo_.occbin.smoother.error_flag=322; end else disp('occbin.DSGE_smoother: smoother converged.') diff --git a/matlab/dynare_estimation_1.m b/matlab/dynare_estimation_1.m index 9de11f35bdeec6339a639078f4501eb7599b83df..8bb1337aeeac801bcbc98683ef86fcac38a202a9 100644 --- a/matlab/dynare_estimation_1.m +++ b/matlab/dynare_estimation_1.m @@ -194,8 +194,10 @@ if isequal(options_.mode_compute,0) && isempty(options_.mode_file) && ~options_. else if options_.occbin.smoother.status [atT,innov,measurement_error,updated_variables,ys,trend_coeff,aK,T,R,P,PK,decomp,Trend,state_uncertainty,M_,oo_,bayestopt_] = occbin.DSGE_smoother(xparam1,gend,transpose(data),data_index,missing_value,M_,oo_,options_,bayestopt_,estim_params_,dataset_,dataset_info); - if oo_.occbin.smoother.error_flag==0 + if oo_.occbin.smoother.error_flag(1)==0 [oo_]=store_smoother_results(M_,oo_,options_,bayestopt_,dataset_,dataset_info,atT,innov,measurement_error,updated_variables,ys,trend_coeff,aK,P,PK,decomp,Trend,state_uncertainty); + else + fprintf('\nOccbin: smoother did not succeed. No results will be written to oo_.\n') end else [atT,innov,measurement_error,updated_variables,ys,trend_coeff,aK,T,R,P,PK,decomp,Trend,state_uncertainty,M_,oo_,bayestopt_] = DsgeSmoother(xparam1,gend,transpose(data),data_index,missing_value,M_,oo_,options_,bayestopt_,estim_params_); @@ -619,8 +621,10 @@ if (~((any(bayestopt_.pshape > 0) && options_.mh_replic) || (any(bayestopt_.psha else if options_.occbin.smoother.status [atT,innov,measurement_error,updated_variables,ys,trend_coeff,aK,T,R,P,PK,decomp,Trend,state_uncertainty,M_,oo_,bayestopt_] = occbin.DSGE_smoother(xparam1,dataset_.nobs,transpose(dataset_.data),dataset_info.missing.aindex,dataset_info.missing.state,M_,oo_,options_,bayestopt_,estim_params_,dataset_,dataset_info); - if oo_.occbin.smoother.error_flag==0 + if oo_.occbin.smoother.error_flag(1)==0 [oo_,yf]=store_smoother_results(M_,oo_,options_,bayestopt_,dataset_,dataset_info,atT,innov,measurement_error,updated_variables,ys,trend_coeff,aK,P,PK,decomp,Trend,state_uncertainty); + else + fprintf('\nOccbin: smoother did not succeed. No results will be written to oo_.\n') end else [atT,innov,measurement_error,updated_variables,ys,trend_coeff,aK,T,R,P,PK,decomp,Trend,state_uncertainty,M_,oo_,bayestopt_] = DsgeSmoother(xparam1,dataset_.nobs,transpose(dataset_.data),dataset_info.missing.aindex,dataset_info.missing.state,M_,oo_,options_,bayestopt_,estim_params_); diff --git a/matlab/get_error_message.m b/matlab/get_error_message.m index 57063a7d4bb2dc005b92d14b2fb05318945250c7..4f57c869b1c42cac7be76b2c08a57ab0636151ca 100644 --- a/matlab/get_error_message.m +++ b/matlab/get_error_message.m @@ -192,6 +192,10 @@ switch info(1) message = 'Occbin: Simulation did not converge -- infinite loop of guess regimes'; case 320 message = 'Piecewise linear Kalman filter: There was a problem in obtaining the likelihood.'; + case 321 + message = 'Occbin: there was a problem in running the smoother. Simulation within smoother failed.'; + case 322 + message = 'Occbin: smoother did not converge.'; case 401 message = 'Cycle reduction reached the iteration limit. Try increasing maxit.'; case 402 diff --git a/matlab/prior_posterior_statistics_core.m b/matlab/prior_posterior_statistics_core.m index 1125328e2c5a0fb6542106a9ed182771b9fefe2d..7d04d28450e4df46fbf949220aa6eeaf5116c63f 100644 --- a/matlab/prior_posterior_statistics_core.m +++ b/matlab/prior_posterior_statistics_core.m @@ -226,8 +226,13 @@ for b=fpar:B if options_.occbin.smoother.status opts_local.occbin.simul.waitbar=0; opts_local.occbin.smoother.waitbar = 0; + opts_local.occbin.smoother.linear_smoother=false; % speed-up [alphahat,etahat,epsilonhat,alphatilde,SteadyState,trend_coeff,aK,~,~,P,~,~,trend_addition,state_uncertainty,M_,oo_,bayestopt_] = ... occbin.DSGE_smoother(deep,gend,Y,data_index,missing_value,M_,oo_,opts_local,bayestopt_,estim_params_); + if oo_.occbin.smoother.error_flag(1) + message=get_error_message(oo_.occbin.smoother.error_flag,opts_local); + fprintf('\nprior_posterior_statistics: One of the draws failed with the error:\n%s\n',message) + end else [alphahat,etahat,epsilonhat,alphatilde,SteadyState,trend_coeff,aK,~,~,P,~,~,trend_addition,state_uncertainty,M_,oo_,bayestopt_] = ... DsgeSmoother(deep,gend,Y,data_index,missing_value,M_,oo_,opts_local,bayestopt_,estim_params_);