SMC: gracefully exit with unsupported options

master^2
Johannes Pfeifer 2024-02-19 14:19:55 +01:00
parent 1ce40d4df5
commit 5d47ac2aa9
3 changed files with 50 additions and 33 deletions

View File

@ -7490,7 +7490,8 @@ observed variables.
Instructs Dynare to use the *Herbst and Schorfheide (2014)*
version of the Sequential Monte-Carlo sampler instead of the
standard Random-Walk Metropolis-Hastings.
standard Random-Walk Metropolis-Hastings. Does not yet support
``moments_varendo``, ``bayesian_irf``, and ``smoother``.
``'dsmh'``

View File

@ -493,15 +493,22 @@ if issmc(options_) || (any(bayestopt_.pshape>0) && options_.mh_replic) || (any(
end
if ~issmc(options_)
[error_flag, ~, options_]= metropolis_draw(1, options_, estim_params_, M_);
else
error_flag=false;
end
if ~(~isempty(options_.sub_draws) && options_.sub_draws==0)
if options_.bayesian_irf
if ~issmc(options_)
if error_flag
error('%s: I cannot compute the posterior IRFs!',dispString)
end
oo_=PosteriorIRF('posterior',options_,estim_params_,oo_,M_,bayestopt_,dataset_,dataset_info,dispString);
else
fprintf('%s: SMC does not yet support the bayesian_irf option. Skipping computation.\n',dispString);
end
end
if options_.moments_varendo
if ~issmc(options_)
if error_flag
error('%s: I cannot compute the posterior moments for the endogenous variables!',dispString)
end
@ -525,8 +532,12 @@ if issmc(options_) || (any(bayestopt_.pshape>0) && options_.mh_replic) || (any(
end
end
oo_ = compute_moments_varendo('posterior',options_,M_,oo_,estim_params_,var_list_);
else
fprintf('%s: SMC does not yet support the moments_varendo option. Skipping computation.\n',dispString);
end
end
if options_.smoother || ~isempty(options_.filter_step_ahead) || options_.forecast
if ~ishssmc(options_)
if error_flag
error('%s: I cannot compute the posterior statistics!',dispString)
end
@ -535,9 +546,12 @@ if issmc(options_) || (any(bayestopt_.pshape>0) && options_.mh_replic) || (any(
else
error('%s: Particle Smoothers are not yet implemented.',dispString)
end
else
fprintf('%s: SMC does not yet support the smoother and forecast options. Skipping computation.\n',dispString);
end
end
else
fprintf('%s: sub_draws was set to 0. Skipping posterior computations.',dispString);
fprintf('%s: sub_draws was set to 0. Skipping posterior computations.\n',dispString);
end
xparam1 = get_posterior_parameters('mean',M_,estim_params_,oo_,options_);
M_ = set_all_parameters(xparam1,estim_params_,M_);

View File

@ -86,6 +86,8 @@ estimation(order=1, datafile='../fsdat_simul.m', nobs=192, loglinear,
posterior_sampling_method='hssmc',
posterior_sampler_options=('steps',10,
'lambda',2,
'particles', 20000,
'particles', 5000,
'scale',.5,
'target', .25));
'target', .25),
bayesian_irf, smoother, moments_varendo,consider_all_endogenous
);