From b835741c41a6409133cc0b97c00d4ab646113322 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=B3ra=20Kocsis?= <dora@dynare.org> Date: Thu, 27 Feb 2020 11:49:40 +0100 Subject: [PATCH] add posterior_sampling_method to estimation options, closes Dynare/matlab-gui#10 --- src/+gui_auxiliary/command_option_mapping.m | 8 ++++---- .../dynare_command_options_estimation.m | 14 ++++++++++---- src/+gui_auxiliary/set_command_option.m | 11 ++++++++++- 3 files changed, 24 insertions(+), 9 deletions(-) diff --git a/src/+gui_auxiliary/command_option_mapping.m b/src/+gui_auxiliary/command_option_mapping.m index 4ce87e9..f48f155 100644 --- a/src/+gui_auxiliary/command_option_mapping.m +++ b/src/+gui_auxiliary/command_option_mapping.m @@ -80,14 +80,14 @@ switch name case 'geweke_interval' mapping = 'convergence.geweke.geweke_interval'; - case 'use_tarb' - mapping = 'TaRB.use_TaRB'; + case 'posterior_sampling_method' + mapping = 'posterior_sampler_options.posterior_sampling_method'; case 'tarb_new_block_probability' - mapping = 'TaRB.new_block_probability'; + mapping = 'posterior_sampler_options.tarb.new_block_probability'; case 'tarb_mode_compute' - mapping = 'TaRB.mode_compute'; + mapping = 'posterior_sampler_options.tarb.mode_compute'; case 'no_posterior_kernel_density' mapping = 'estimation.moments_posterior_density.indicator'; diff --git a/src/+gui_auxiliary/dynare_command_options_estimation.m b/src/+gui_auxiliary/dynare_command_options_estimation.m index bdcc007..14153a2 100644 --- a/src/+gui_auxiliary/dynare_command_options_estimation.m +++ b/src/+gui_auxiliary/dynare_command_options_estimation.m @@ -338,10 +338,16 @@ dynare_gui_.estimation.MH_options{num,3} = '[DOUBLE DOUBLE]'; %special dynare_gui_.estimation.MH_options{num,4} = 'Percentage of MCMC draws at the beginning and end of the MCMC chain taken to compute the Geweke (1992,1999) convergence diagnostics (requires [mh nblocks]=1) after discarding the first [mh drop], page 54 percent of draws as a burnin. Default: [0.2 0.5].'; num = num+1; -dynare_gui_.estimation.MH_options{num,1} = 'use_tarb'; -dynare_gui_.estimation.MH_options{num,2} = 0; -dynare_gui_.estimation.MH_options{num,3} = 'check_option'; -dynare_gui_.estimation.MH_options{num,4} = 'Instructs Dynare to use the Tailored randomized block (TaRB) Metropolis-Hastings algorithm proposed by Chib and Ramamurthy (2010) instead of the standard Random-Walk Metropolis-Hastings.'; +dynare_gui_.estimation.MH_options{num,1} = 'posterior_sampling_method'; +dynare_gui_.estimation.MH_options{num,2} = 'random_walk_metropolis_hastings'; +dynare_gui_.estimation.MH_options{num,3} = {'random_walk_metropolis_hastings', 'tailored_random_block_metropolis_hastings', 'independent_metropolis_hastings', 'slice'}; +dynare_gui_.estimation.MH_options{num,4} = "Tells Dynare which sampler method should be used to sample from the posterior distribution during Bayesian estimation. The default setting is the standard Random-Walk Metropolis-Hastings. The following alternative methods are available: Tailored randomized block (TaRB) Metropolis-Hastings algorithm proposed by Chib and Ramamurthy (2010), Independent Metropolis-Hastings algorithm where the proposal distribution does not depend on the state of the chain, Slice sampler of Planas, Ratto, and Rossi (2015). (Note that 'slice' is incompatible with prior_trunc=0.)"; + +% num = num+1; +% dynare_gui_.estimation.MH_options{num,1} = 'use_tarb'; +% dynare_gui_.estimation.MH_options{num,2} = 0; +% dynare_gui_.estimation.MH_options{num,3} = 'check_option'; +% dynare_gui_.estimation.MH_options{num,4} = 'Instructs Dynare to use the Tailored randomized block (TaRB) Metropolis-Hastings algorithm proposed by Chib and Ramamurthy (2010) instead of the standard Random-Walk Metropolis-Hastings.'; num = num+1; dynare_gui_.estimation.MH_options{num,1} = 'tarb_new_block_probability'; diff --git a/src/+gui_auxiliary/set_command_option.m b/src/+gui_auxiliary/set_command_option.m index 3c69a46..90865f0 100644 --- a/src/+gui_auxiliary/set_command_option.m +++ b/src/+gui_auxiliary/set_command_option.m @@ -116,7 +116,16 @@ try case 'mh_recover' options_.mh_recover = logical(value); - + + case 'posterior_sampling_method' + if value == 2 + eval(['options_.' gui_auxiliary.command_option_mapping(name) '= tailored_random_block_metropolis_hastings;']); + elseif value == 3 + eval(['options_.' gui_auxiliary.command_option_mapping(name) '= independent_metropolis_hastings;']); + elseif value == 4 + eval(['options_.' gui_auxiliary.command_option_mapping(name) '= slice;']); + end + otherwise if isnumeric(value) eval(['options_.' gui_auxiliary.command_option_mapping(name) '=' num2str(value) ';']); -- GitLab