From 47ecf406a1a46c134feb0f2a7966e84469a27c52 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=B3ra=20Kocsis?= <dora@dynare.org> Date: Thu, 27 Feb 2020 18:48:22 +0100 Subject: [PATCH] add posterior_sampling_method to estimation options, closes Dynare/matlab-gui#10 --- src/+gui_auxiliary/command_option_mapping.m | 9 ----- .../dynare_command_options_estimation.m | 33 +++++-------------- src/+gui_auxiliary/set_command_option.m | 12 +++++++ 3 files changed, 20 insertions(+), 34 deletions(-) diff --git a/src/+gui_auxiliary/command_option_mapping.m b/src/+gui_auxiliary/command_option_mapping.m index 4ce87e9..3382c1d 100644 --- a/src/+gui_auxiliary/command_option_mapping.m +++ b/src/+gui_auxiliary/command_option_mapping.m @@ -80,15 +80,6 @@ switch name case 'geweke_interval' mapping = 'convergence.geweke.geweke_interval'; - case 'use_tarb' - mapping = 'TaRB.use_TaRB'; - - case 'tarb_new_block_probability' - mapping = 'TaRB.new_block_probability'; - - case 'tarb_mode_compute' - mapping = '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..ba7acff 100644 --- a/src/+gui_auxiliary/dynare_command_options_estimation.m +++ b/src/+gui_auxiliary/dynare_command_options_estimation.m @@ -338,33 +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} = 'tarb_new_block_probability'; -dynare_gui_.estimation.MH_options{num,2} = '0.25'; -dynare_gui_.estimation.MH_options{num,3} = 'DOUBLE'; -dynare_gui_.estimation.MH_options{num,4} = 'Specifies the probability of the next parameter belonging to a new block when the random blocking in the TaRB Metropolis-Hastings algorithm is conducted. The higher this number, the smaller is the average block size and the more random blocks are formed during each parameter sweep. Default: 0.25.'; - -num = num+1; -dynare_gui_.estimation.MH_options{num,1} = 'tarb_mode_compute'; -dynare_gui_.estimation.MH_options{num,2} = '4'; -dynare_gui_.estimation.MH_options{num,3} = 'INTEGER'; -dynare_gui_.estimation.MH_options{num,4} = 'Specifies the mode-finder run in every iteration for every block of the TaRB Metropolis-Hastings algorithm. See [mode compute]. Default: 4.'; - -% There is no field in options_ structure for tarb_optim -% num = num+1; -% dynare_gui_.estimation.MH_options{num,1} = 'tarb_optim'; -% dynare_gui_.estimation.MH_options{num,2} = ''; -% dynare_gui_.estimation.MH_options{num,3} = 'INTEGER'; -% dynare_gui_.estimation.MH_options{num,4} = 'Specifies the options for the mode-finder used in the TaRB Metropolis-Hastings algorithm. See [optim].'; - - - - +dynare_gui_.estimation.MH_options{num,1} = 'posterior_sampler_options'; +dynare_gui_.estimation.MH_options{num,2} = ''; +dynare_gui_.estimation.MH_options{num,3} = '(NAME, VALUE, ...)'; % 'special' +dynare_gui_.estimation.MH_options{num,4} = 'A list of NAME and VALUE pairs. Can be used to set options for the posterior sampling methods. The set of available options depends on the selected samping routine (ie on the value of option [posterior_sampling_method]).'; %% Group 5: filter num = 1; diff --git a/src/+gui_auxiliary/set_command_option.m b/src/+gui_auxiliary/set_command_option.m index 226c492..7a140ee 100644 --- a/src/+gui_auxiliary/set_command_option.m +++ b/src/+gui_auxiliary/set_command_option.m @@ -117,6 +117,18 @@ try case 'mh_recover' options_.mh_recover = logical(value); + case 'posterior_sampling_method' + if value == 2 + options_.posterior_sampler_options.posterior_sampling_method = 'tailored_random_block_metropolis_hastings'; + elseif value == 3 + options_.posterior_sampler_options.posterior_sampling_method = 'independent_metropolis_hastings'; + elseif value == 4 + options_.posterior_sampler_options.posterior_sampling_method = 'slice'; + end + + case 'posterior_sampler_options' + options_.posterior_sampler_options.sampling_opt = value; + otherwise if isnumeric(value) eval(['options_.' gui_auxiliary.command_option_mapping(name) '=' num2str(value) ';']); -- GitLab