diff --git a/matlab/default_option_values.m b/matlab/default_option_values.m index 66ba29f13..5bffa1e2e 100644 --- a/matlab/default_option_values.m +++ b/matlab/default_option_values.m @@ -425,7 +425,7 @@ options_.smoother = false; options_.posterior_max_subsample_draws = 1200; options_.sub_draws = []; options_.ME_plot_tol=1e-6; -% options_.use_mh_covariance_matrix = 0; +options_.use_mh_covariance_matrix = false; options_.gradient_method = 2; %used by csminwel and newrat options_.gradient_epsilon = 1e-6; %used by csminwel and newrat options_.posterior_sampler_options.sampling_opt = []; %extended set of options for individual posterior samplers diff --git a/matlab/posterior_sampler_initialization.m b/matlab/posterior_sampler_initialization.m index 069985fa4..89b9e96d2 100644 --- a/matlab/posterior_sampler_initialization.m +++ b/matlab/posterior_sampler_initialization.m @@ -490,24 +490,29 @@ elseif options_.mh_recover end function [d,bayestopt_]=set_proposal_density_to_previous_value(record,options_,bayestopt_,d) -if isfield(record,'ProposalCovariance') && isfield(record,'ProposalCovariance') - if isfield(record,'MCMC_sampler') - if ~strcmp(record.MCMC_sampler,options_.posterior_sampler_options.posterior_sampling_method) - error(fprintf('Estimation::mcmc: The posterior_sampling_method differs from the one of the original chain. Please reset it to %s',record.MCMC_sampler)) +if ~options_.use_mh_covariance_matrix + if isfield(record,'ProposalCovariance') && isfield(record,'ProposalScaleVec') + if isfield(record,'MCMC_sampler') + if ~strcmp(record.MCMC_sampler,options_.posterior_sampler_options.posterior_sampling_method) + error(fprintf('Estimation::mcmc: The posterior_sampling_method differs from the one of the original chain. Please reset it to %s',record.MCMC_sampler)) + end + end + fprintf('Estimation::mcmc: Recovering the previous proposal density.\n') + d=record.ProposalCovariance; + bayestopt_.jscale=record.ProposalScaleVec; + else + if ~isequal(options_.posterior_sampler_options.posterior_sampling_method,'slice') + % pass through input d unaltered + if options_.mode_compute~=0 + fprintf('Estimation::mcmc: No stored previous proposal density found, continuing with the one implied by mode_compute\n.'); + elseif ~isempty(options_.mode_file) + fprintf('Estimation::mcmc: No stored previous proposal density found, continuing with the one implied by the mode_file\n.'); + else + error('Estimation::mcmc: No stored previous proposal density found, no mode-finding conducted, and no mode-file provided. I don''t know how to continue') + end end end - fprintf('Estimation::mcmc: Recovering the previous proposal density.\n') - d=record.ProposalCovariance; - bayestopt_.jscale=record.ProposalScaleVec; else - if ~isequal(options_.posterior_sampler_options.posterior_sampling_method,'slice') - % pass through input d unaltered - if options_.mode_compute~=0 - fprintf('Estimation::mcmc: No stored previous proposal density found, continuing with the one implied by mode_compute\n.'); - elseif ~isempty(options_.mode_file) - fprintf('Estimation::mcmc: No stored previous proposal density found, continuing with the one implied by the mode_file\n.'); - else - error('Estimation::mcmc: No stored previous proposal density found, no mode-finding conducted, and no mode-file provided. I don''t know how to continue') - end - end -end + % pass through input d unaltered + fprintf('Estimation::mcmc: use_mh_covariance_matrix specified, continuing with proposal density implied by the previous MCMC run.\n.'); +end \ No newline at end of file