diff --git a/matlab/posterior_sampler_initialization.m b/matlab/posterior_sampler_initialization.m index aaddd9b70..b950d3861 100644 --- a/matlab/posterior_sampler_initialization.m +++ b/matlab/posterior_sampler_initialization.m @@ -225,7 +225,6 @@ if ~options_.load_mh_file && ~options_.mh_recover record.LastFileNumber = AnticipatedNumberOfFiles ; record.LastLineNumber = AnticipatedNumberOfLinesInTheLastFile; record.MCMCConcludedSuccessfully = 0; - record.MCMC_sampler=options_.posterior_sampler_options.posterior_sampling_method; record.ProposalScaleVec=bayestopt_.jscale; fprintf('Ok!\n'); id = write_mh_history_file(MetropolisFolder, ModelName, record); @@ -286,7 +285,7 @@ elseif options_.load_mh_file && ~options_.mh_recover end ilogpo2 = record.LastLogPost; ix2 = record.LastParameters; - [d,bayestopt_]=set_proposal_density_to_previous_value(record,options_,bayestopt_,d); + [d,bayestopt_,record]=set_proposal_density_to_previous_value(record,options_,bayestopt_,d); FirstBlock = 1; NumberOfPreviousSimulations = sum(record.MhDraws(:,1),1); fprintf('Estimation::mcmc: I am writing a new mh-history file... '); @@ -368,7 +367,7 @@ elseif options_.mh_recover LastFileFullIndicator=1; end if ~isequal(options_.posterior_sampler_options.posterior_sampling_method,'slice') - [d,bayestopt_]=set_proposal_density_to_previous_value(record,options_,bayestopt_,d); + [d,bayestopt_,record]=set_proposal_density_to_previous_value(record,options_,bayestopt_,d); end %% Now find out what exactly needs to be redone % 1. Check if really something needs to be done @@ -489,14 +488,9 @@ elseif options_.mh_recover FirstBlock = find(FBlock==1,1); end -function [d,bayestopt_]=set_proposal_density_to_previous_value(record,options_,bayestopt_,d) +function [d,bayestopt_,record]=set_proposal_density_to_previous_value(record,options_,bayestopt_,d) 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) - warning('Estimation::mcmc: The posterior_sampling_method %s selected differs from the %s of the original chain. This may create problems with the convergence diagnostics.',options_.posterior_sampler_options.posterior_sampling_method,record.MCMC_sampler) - end - end fprintf('Estimation::mcmc: Recovering the previous proposal density.\n') d=record.ProposalCovariance; bayestopt_.jscale=record.ProposalScaleVec; @@ -515,4 +509,11 @@ if ~options_.use_mh_covariance_matrix else % 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 +end + +if isfield(record,'Sampler') + if ~strcmp(record.Sampler,options_.posterior_sampler_options.posterior_sampling_method) + warning('Estimation::mcmc: The posterior_sampling_method %s selected differs from the %s of the original chain. This may create problems with the convergence diagnostics.',options_.posterior_sampler_options.posterior_sampling_method,record.Sampler) + record.Sampler=options_.posterior_sampler_options.posterior_sampling_method; %update sampler used + end +end