diff --git a/matlab/estimation/prior_posterior_statistics_core.m b/matlab/estimation/prior_posterior_statistics_core.m index 5cf8f364e5ff56e0b1de55f0842b981effb04afa..332637302957dee6ad71ccc4666ac8617c3fb832 100644 --- a/matlab/estimation/prior_posterior_statistics_core.m +++ b/matlab/estimation/prior_posterior_statistics_core.m @@ -230,11 +230,27 @@ for b=fpar:B 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,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) + if options_.occbin.smoother.inversion_filter + dataset_.data=Y'; + [~, info, ~, ~, ~, ~, ~, ~, ~, ~, oo_.dr, alphahat, etahat] = ... + occbin.IVF_posterior(deep,dataset_,[],options_,M_,estim_params_,bayestopt_,prior_bounds(bayestopt_,options_.prior_trunc),oo_.dr, oo_.steady_state,oo_.exo_steady_state,oo_.exo_det_steady_state); + if info(1) + message=get_error_message(info,opts_local); + fprintf('\nprior_posterior_statistics: IVF smoother failed for one of the draws:\n%s\n',message) + else + alphatilde = alphahat*nan; + SteadyState=oo_.dr.ys; + trend_coeff = zeros(length(options_.varobs_id),1); + trend_addition=zeros(options_.number_of_observed_variables,gend); + end + %epsilonhat not available as no measurement error allowed + else + [alphahat,etahat,epsilonhat,alphatilde,SteadyState,trend_coeff,aK,~,~,P,~,~,trend_addition,state_uncertainty,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 end else [alphahat,etahat,epsilonhat,alphatilde,SteadyState,trend_coeff,aK,~,~,P,~,~,trend_addition,state_uncertainty,oo_,bayestopt_] = ... diff --git a/tests/occbin/filter/NKM.mod b/tests/occbin/filter/NKM.mod index a54142f94ad7f1c928af1183ac1c8b716bd12ba1..07166af5dbf19a864953602ae93b753da010d6ae 100644 --- a/tests/occbin/filter/NKM.mod +++ b/tests/occbin/filter/NKM.mod @@ -417,6 +417,12 @@ varobs yg inom pi; legend('PKF','IF') occbin_write_regimes(smoother); + estimation( + datafile=dataobsfile2, mode_file=NKM_mh_mode_saved, + mode_compute=0, nobs=120, first_obs=1, + mh_replic=10, plot_priors=0, smoother, + consider_all_endogenous,heteroskedastic_filter,filter_step_ahead=[1:8],smoothed_state_uncertainty); + write_latex_dynamic_model; collect_latex_files; [status, cmdout]=system(['pdflatex -halt-on-error -interaction=nonstopmode ' M_.fname '_TeX_binder.tex']);