From c1483b4c615950a50d723335d0528c08bfa471d2 Mon Sep 17 00:00:00 2001 From: Johannes Pfeifer Date: Wed, 13 Oct 2021 09:51:35 +0200 Subject: [PATCH] Restore backward-compatibility when using load_mh_file estim_params_ needs to be saved following 6e06acc7 --- matlab/dynare_estimation_1.m | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/matlab/dynare_estimation_1.m b/matlab/dynare_estimation_1.m index 49df96c69..bfcdf9d55 100644 --- a/matlab/dynare_estimation_1.m +++ b/matlab/dynare_estimation_1.m @@ -545,6 +545,16 @@ if (any(bayestopt_.pshape >0 ) && options_.mh_replic) || ... for ii=1:length(generic_post_data_file_name) delete_stale_file([MetropolisFolder filesep M_.fname '_' generic_post_data_file_name{1,ii} '*']); end + % restore compatibility for loading pre-4.6.2 runs where estim_params_ was not saved; see 6e06acc7 and !1944 + NumberOfDrawsFiles = length(dir([M_.dname '/metropolis/' M_.fname '_posterior_draws*' ])); + if NumberOfDrawsFiles>0 + temp=load([M_.dname '/metropolis/' M_.fname '_posterior_draws1']); + if ~isfield(temp,'estim_params_') + for file_iter=1:NumberOfDrawsFiles + save([M_.dname '/metropolis/' M_.fname '_posterior_draws' num2str(file_iter)],'estim_params_','-append') + end + end + end end end oo_ = compute_moments_varendo('posterior',options_,M_,oo_,var_list_);