SMC: gracefully exit with unsupported options
parent
1ce40d4df5
commit
5d47ac2aa9
|
@ -7490,7 +7490,8 @@ observed variables.
|
||||||
|
|
||||||
Instructs Dynare to use the *Herbst and Schorfheide (2014)*
|
Instructs Dynare to use the *Herbst and Schorfheide (2014)*
|
||||||
version of the Sequential Monte-Carlo sampler instead of the
|
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'``
|
``'dsmh'``
|
||||||
|
|
||||||
|
|
|
@ -493,52 +493,66 @@ if issmc(options_) || (any(bayestopt_.pshape>0) && options_.mh_replic) || (any(
|
||||||
end
|
end
|
||||||
if ~issmc(options_)
|
if ~issmc(options_)
|
||||||
[error_flag, ~, options_]= metropolis_draw(1, options_, estim_params_, M_);
|
[error_flag, ~, options_]= metropolis_draw(1, options_, estim_params_, M_);
|
||||||
|
else
|
||||||
|
error_flag=false;
|
||||||
end
|
end
|
||||||
if ~(~isempty(options_.sub_draws) && options_.sub_draws==0)
|
if ~(~isempty(options_.sub_draws) && options_.sub_draws==0)
|
||||||
if options_.bayesian_irf
|
if options_.bayesian_irf
|
||||||
if error_flag
|
if ~issmc(options_)
|
||||||
error('%s: I cannot compute the posterior IRFs!',dispString)
|
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
|
||||||
oo_=PosteriorIRF('posterior',options_,estim_params_,oo_,M_,bayestopt_,dataset_,dataset_info,dispString);
|
|
||||||
end
|
end
|
||||||
if options_.moments_varendo
|
if options_.moments_varendo
|
||||||
if error_flag
|
if ~issmc(options_)
|
||||||
error('%s: I cannot compute the posterior moments for the endogenous variables!',dispString)
|
if error_flag
|
||||||
end
|
error('%s: I cannot compute the posterior moments for the endogenous variables!',dispString)
|
||||||
if options_.load_mh_file && options_.mh_replic==0 %user wants to recompute results
|
end
|
||||||
[MetropolisFolder, info] = CheckPath('metropolis',M_.dname);
|
if options_.load_mh_file && options_.mh_replic==0 %user wants to recompute results
|
||||||
if ~info
|
[MetropolisFolder, info] = CheckPath('metropolis',M_.dname);
|
||||||
generic_post_data_file_name={'Posterior2ndOrderMoments','decomposition','PosteriorVarianceDecomposition','correlation','PosteriorCorrelations','conditional decomposition','PosteriorConditionalVarianceDecomposition'};
|
if ~info
|
||||||
for ii=1:length(generic_post_data_file_name)
|
generic_post_data_file_name={'Posterior2ndOrderMoments','decomposition','PosteriorVarianceDecomposition','correlation','PosteriorCorrelations','conditional decomposition','PosteriorConditionalVarianceDecomposition'};
|
||||||
delete_stale_file([MetropolisFolder filesep M_.fname '_' generic_post_data_file_name{1,ii} '*']);
|
for ii=1:length(generic_post_data_file_name)
|
||||||
end
|
delete_stale_file([MetropolisFolder filesep M_.fname '_' generic_post_data_file_name{1,ii} '*']);
|
||||||
% restore compatibility for loading pre-4.6.2 runs where estim_params_ was not saved; see 6e06acc7 and !1944
|
end
|
||||||
NumberOfDrawsFiles = length(dir([M_.dname '/metropolis/' M_.fname '_posterior_draws*' ]));
|
% restore compatibility for loading pre-4.6.2 runs where estim_params_ was not saved; see 6e06acc7 and !1944
|
||||||
if NumberOfDrawsFiles>0
|
NumberOfDrawsFiles = length(dir([M_.dname '/metropolis/' M_.fname '_posterior_draws*' ]));
|
||||||
temp=load([M_.dname '/metropolis/' M_.fname '_posterior_draws1']);
|
if NumberOfDrawsFiles>0
|
||||||
if ~isfield(temp,'estim_params_')
|
temp=load([M_.dname '/metropolis/' M_.fname '_posterior_draws1']);
|
||||||
for file_iter=1:NumberOfDrawsFiles
|
if ~isfield(temp,'estim_params_')
|
||||||
save([M_.dname '/metropolis/' M_.fname '_posterior_draws' num2str(file_iter)],'estim_params_','-append')
|
for file_iter=1:NumberOfDrawsFiles
|
||||||
|
save([M_.dname '/metropolis/' M_.fname '_posterior_draws' num2str(file_iter)],'estim_params_','-append')
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
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
|
||||||
oo_ = compute_moments_varendo('posterior',options_,M_,oo_,estim_params_,var_list_);
|
|
||||||
end
|
end
|
||||||
if options_.smoother || ~isempty(options_.filter_step_ahead) || options_.forecast
|
if options_.smoother || ~isempty(options_.filter_step_ahead) || options_.forecast
|
||||||
if error_flag
|
if ~ishssmc(options_)
|
||||||
error('%s: I cannot compute the posterior statistics!',dispString)
|
if error_flag
|
||||||
end
|
error('%s: I cannot compute the posterior statistics!',dispString)
|
||||||
if options_.order==1 && ~options_.particle.status
|
end
|
||||||
oo_=prior_posterior_statistics('posterior',dataset_,dataset_info,M_,oo_,options_,estim_params_,bayestopt_,dispString); %get smoothed and filtered objects and forecasts
|
if options_.order==1 && ~options_.particle.status
|
||||||
|
oo_=prior_posterior_statistics('posterior',dataset_,dataset_info,M_,oo_,options_,estim_params_,bayestopt_,dispString); %get smoothed and filtered objects and forecasts
|
||||||
|
else
|
||||||
|
error('%s: Particle Smoothers are not yet implemented.',dispString)
|
||||||
|
end
|
||||||
else
|
else
|
||||||
error('%s: Particle Smoothers are not yet implemented.',dispString)
|
fprintf('%s: SMC does not yet support the smoother and forecast options. Skipping computation.\n',dispString);
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
else
|
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
|
end
|
||||||
xparam1 = get_posterior_parameters('mean',M_,estim_params_,oo_,options_);
|
xparam1 = get_posterior_parameters('mean',M_,estim_params_,oo_,options_);
|
||||||
M_ = set_all_parameters(xparam1,estim_params_,M_);
|
M_ = set_all_parameters(xparam1,estim_params_,M_);
|
||||||
end
|
end
|
||||||
|
|
|
@ -86,6 +86,8 @@ estimation(order=1, datafile='../fsdat_simul.m', nobs=192, loglinear,
|
||||||
posterior_sampling_method='hssmc',
|
posterior_sampling_method='hssmc',
|
||||||
posterior_sampler_options=('steps',10,
|
posterior_sampler_options=('steps',10,
|
||||||
'lambda',2,
|
'lambda',2,
|
||||||
'particles', 20000,
|
'particles', 5000,
|
||||||
'scale',.5,
|
'scale',.5,
|
||||||
'target', .25));
|
'target', .25),
|
||||||
|
bayesian_irf, smoother, moments_varendo,consider_all_endogenous
|
||||||
|
);
|
||||||
|
|
Loading…
Reference in New Issue