diff --git a/doc/dynare.texi b/doc/dynare.texi index 901a3275d..d884995b2 100644 --- a/doc/dynare.texi +++ b/doc/dynare.texi @@ -5763,6 +5763,11 @@ covariance of the proposal distribution. Requires the @ref{load_mh_file}-option Provides the name of a @file{_mh_scale.mat}-file storing the tuned scale factor from a previous run of @code{mode_compute=6} +@item 'save_tmp_file' +@anchor{save_tmp_file} +Save the MCMC draws into a @code{_mh_tmp_blck}-file at the refresh rate of the status bar instead of just saving the draws +when the current @code{_mh*_blck}-file is full. Default: 0 + @end table @item 'independent_metropolis_hastings' @@ -5797,6 +5802,9 @@ Default: 0.8 @item 'use_mh_covariance_matrix' @xref{use_mh_covariance_matrix}. Must be used with @code{'rotated'}. Default: 0 +@item 'save_tmp_file' +@xref{save_tmp_file}. Default: 1. + @end table @item 'tailored_random_block_metropolis_hastings' @@ -5819,6 +5827,9 @@ Metropolis-Hastings algorithm. @xref{optim}. @item 'scale_file' @xref{scale_file}. +@item 'save_tmp_file' +@xref{save_tmp_file}. Default: 1. + @end table @end table diff --git a/matlab/check_posterior_sampler_options.m b/matlab/check_posterior_sampler_options.m index e207f6649..299b4b3f6 100644 --- a/matlab/check_posterior_sampler_options.m +++ b/matlab/check_posterior_sampler_options.m @@ -48,7 +48,6 @@ if init, posterior_sampler_options.serial_bar_refresh_rate=3; posterior_sampler_options.parallel_bar_title='RWMH'; posterior_sampler_options.serial_bar_title='RW Metropolis-Hastings'; - posterior_sampler_options.save_tmp_file=1; % default options posterior_sampler_options = add_fields_(posterior_sampler_options,options_.posterior_sampler_options.rwmh); @@ -95,6 +94,8 @@ if init, else error('initial_estimation_checks:: The specified mh_scale_file does not exist.') end + case 'save_tmp_file' + posterior_sampler_options.save_tmp_file = options_list{i,2}; otherwise warning(['rwmh_sampler: Unknown option (' options_list{i,1} ')!']) end @@ -106,7 +107,6 @@ if init, posterior_sampler_options.serial_bar_refresh_rate=1; posterior_sampler_options.parallel_bar_title='TaRB-MH'; posterior_sampler_options.serial_bar_title='TaRB Metropolis-Hastings'; - posterior_sampler_options.save_tmp_file=1; % default options posterior_sampler_options = add_fields_(posterior_sampler_options,options_.posterior_sampler_options.tarb); @@ -160,7 +160,9 @@ if init, else error('initial_estimation_checks:: The specified scale_file does not exist.') end - + case 'save_tmp_file' + posterior_sampler_options.save_tmp_file = options_list{i,2}; + otherwise warning(['tarb_sampler: Unknown option (' options_list{i,1} ')!']) @@ -175,7 +177,6 @@ if init, posterior_sampler_options.serial_bar_refresh_rate=3; posterior_sampler_options.parallel_bar_title='IMH'; posterior_sampler_options.serial_bar_title='Ind. Metropolis-Hastings'; - posterior_sampler_options.save_tmp_file=1; % default options posterior_sampler_options = add_fields_(posterior_sampler_options,options_.posterior_sampler_options.imh); @@ -210,6 +211,9 @@ if init, posterior_sampler_options.use_mh_covariance_matrix = options_list{i,2}; options_.use_mh_covariance_matrix = options_list{i,2}; + case 'save_tmp_file' + posterior_sampler_options.save_tmp_file = options_list{i,2}; + otherwise warning(['imh_sampler: Unknown option (' options_list{i,1} ')!']) end @@ -222,7 +226,6 @@ if init, posterior_sampler_options.serial_bar_refresh_rate=1; posterior_sampler_options.parallel_bar_title='SLICE'; posterior_sampler_options.serial_bar_title='SLICE'; - posterior_sampler_options.save_tmp_file=1; % default options posterior_sampler_options = add_fields_(posterior_sampler_options,options_.posterior_sampler_options.slice); @@ -292,6 +295,9 @@ if init, % default = 0 posterior_sampler_options.use_mh_covariance_matrix = options_list{i,2}; options_.use_mh_covariance_matrix = options_list{i,2}; + + case 'save_tmp_file' + posterior_sampler_options.save_tmp_file = options_list{i,2}; otherwise warning(['slice_sampler: Unknown option (' options_list{i,1} ')!']) @@ -408,7 +414,7 @@ if strcmp(posterior_sampler_options.posterior_sampling_method,'slice') % % % [junk, invhess] = compute_mh_covariance_matrix; % % % posterior_sampler_options.invhess = invhess; % % % end - [V1 D]=eig(invhess); + [V1, D]=eig(invhess); posterior_sampler_options.V1=V1; posterior_sampler_options.WR=sqrt(diag(D))*3; end diff --git a/matlab/global_initialization.m b/matlab/global_initialization.m index 8c0c01814..0bf7eeee4 100644 --- a/matlab/global_initialization.m +++ b/matlab/global_initialization.m @@ -472,12 +472,14 @@ options_.posterior_sampler_options.posterior_sampling_method = 'random_walk_metr options_.posterior_sampler_options.rwmh.proposal_distribution = 'rand_multivariate_normal'; options_.posterior_sampler_options.rwmh.student_degrees_of_freedom = 3; options_.posterior_sampler_options.rwmh.use_mh_covariance_matrix=0; +options_.posterior_sampler_options.rwmh.save_tmp_file=0; % Tailored Random Block Metropolis-Hastings options_.posterior_sampler_options.tarb.proposal_distribution = 'rand_multivariate_normal'; options_.posterior_sampler_options.tarb.student_degrees_of_freedom = 3; options_.posterior_sampler_options.tarb.mode_compute=4; options_.posterior_sampler_options.tarb.new_block_probability=0.25; %probability that next parameter belongs to new block options_.posterior_sampler_options.tarb.optim_opt=''; %probability that next parameter belongs to new block +options_.posterior_sampler_options.tarb.save_tmp_file=1; % Slice options_.posterior_sampler_options.slice.proposal_distribution = ''; options_.posterior_sampler_options.slice.rotated=0; @@ -487,6 +489,7 @@ options_.posterior_sampler_options.slice.WR=[]; options_.posterior_sampler_options.slice.mode_files=[]; options_.posterior_sampler_options.slice.mode=[]; options_.posterior_sampler_options.slice.initial_step_size=0.8; +options_.posterior_sampler_options.slice.save_tmp_file=1; % Independent Metropolis-Hastings options_.posterior_sampler_options.imh.proposal_distribution = 'rand_multivariate_normal'; options_.posterior_sampler_options.imh.use_mh_covariance_matrix=0; diff --git a/tests/estimation/t_proposal/fs2000_student.mod b/tests/estimation/t_proposal/fs2000_student.mod index d204ffa3e..aa52caf28 100644 --- a/tests/estimation/t_proposal/fs2000_student.mod +++ b/tests/estimation/t_proposal/fs2000_student.mod @@ -115,4 +115,4 @@ end; varobs gp_obs gy_obs; estimation(order=1, datafile='../fsdat_simul',nobs=192, loglinear, mh_replic=2002, mh_nblocks=2, mh_jscale=0.8,mode_compute=4, -posterior_sampler_options=('proposal_distribution','rand_multivariate_student','student_degrees_of_freedom',5)); +posterior_sampler_options=('proposal_distribution','rand_multivariate_student','student_degrees_of_freedom',5,'save_tmp_file',0));