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

:bug: OccBin: clear State_uncertainty field before trying to fill it

Prevents crashes with smoothed_state_uncertainty option if MCMC smoother is run after classical one
parent 87abdff3
Branches
Tags
No related merge requests found
...@@ -141,9 +141,9 @@ if options_.filter_covariance ...@@ -141,9 +141,9 @@ if options_.filter_covariance
filter_covariance=1; filter_covariance=1;
end end
smoothed_state_uncertainty=0; smoothed_state_uncertainty=false;
if options_.smoothed_state_uncertainty if options_.smoothed_state_uncertainty
smoothed_state_uncertainty=1; smoothed_state_uncertainty=true;
end end
% Store the variable mandatory for local/remote parallel computing. % Store the variable mandatory for local/remote parallel computing.
...@@ -327,6 +327,9 @@ if options_.smoother ...@@ -327,6 +327,9 @@ if options_.smoother
varlist,'UpdatedVariables',DirectoryName, ... varlist,'UpdatedVariables',DirectoryName, ...
'_update',dispString); '_update',dispString);
if smoothed_state_uncertainty if smoothed_state_uncertainty
if isfield(oo_,'Smoother') && isfield(oo_.Smoother,'State_uncertainty')
oo_.Smoother=rmfield(oo_.Smoother,'State_uncertainty'); %needs to be removed as classical smoother field has a different format
end
oo_=pm3(M_,options_,oo_,endo_nbr,endo_nbr,ifil(13),B,'State Uncertainty',... oo_=pm3(M_,options_,oo_,endo_nbr,endo_nbr,ifil(13),B,'State Uncertainty',...
varlist,M_.endo_names_tex,M_.endo_names,... varlist,M_.endo_names_tex,M_.endo_names,...
varlist,'StateUncertainty',DirectoryName,'_state_uncert',dispString); varlist,'StateUncertainty',DirectoryName,'_state_uncert',dispString);
......
...@@ -389,13 +389,22 @@ varobs yg inom pi; ...@@ -389,13 +389,22 @@ varobs yg inom pi;
else else
disp('smoother redux successfully recovers full k-step ahead variables results!') disp('smoother redux successfully recovers full k-step ahead variables results!')
end end
//run PKF with MCMC
options_.smoother_redux=false;
estimation(
datafile=dataobsfile2, mode_file=NKM_mh_mode_saved,
mode_compute=0, nobs=120, first_obs=1,
mh_replic=50, plot_priors=0, smoother,
consider_all_endogenous,heteroskedastic_filter,filter_step_ahead=[1:8],smoothed_state_uncertainty);
// use inversion filter (note that IF provides smoother together with likelihood) // use inversion filter (note that IF provides smoother together with likelihood)
occbin_setup(likelihood_inversion_filter,smoother_inversion_filter); occbin_setup(likelihood_inversion_filter,smoother_inversion_filter);
estimation( estimation(
datafile=dataobsfile2, mode_file=NKM_mh_mode_saved, datafile=dataobsfile2, mode_file=NKM_mh_mode_saved,
mode_compute=0, nobs=120, first_obs=1, mode_compute=0, nobs=120, first_obs=1,
mh_replic=0, plot_priors=0, smoother, mh_replic=50, plot_priors=0, smoother,
consider_all_endogenous,heteroskedastic_filter,filter_step_ahead=[1:8],smoothed_state_uncertainty); consider_all_endogenous,heteroskedastic_filter,filter_step_ahead=[1:8],smoothed_state_uncertainty);
// show initial condition effect of IF // show initial condition effect of IF
...@@ -420,7 +429,7 @@ varobs yg inom pi; ...@@ -420,7 +429,7 @@ varobs yg inom pi;
estimation( estimation(
datafile=dataobsfile2, mode_file=NKM_mh_mode_saved, datafile=dataobsfile2, mode_file=NKM_mh_mode_saved,
mode_compute=0, nobs=120, first_obs=1, mode_compute=0, nobs=120, first_obs=1,
mh_replic=10, plot_priors=0, smoother, mh_replic=50, plot_priors=0, smoother,
consider_all_endogenous,heteroskedastic_filter,filter_step_ahead=[1:8],smoothed_state_uncertainty); consider_all_endogenous,heteroskedastic_filter,filter_step_ahead=[1:8],smoothed_state_uncertainty);
write_latex_dynamic_model; write_latex_dynamic_model;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment