diff --git a/matlab/dynare_estimation_1.m b/matlab/dynare_estimation_1.m index cd035c37fd2d93b8d5e7806bfd6e4c7b3d6de5e4..6693768cec75be1c325076369296764014a39310 100644 --- a/matlab/dynare_estimation_1.m +++ b/matlab/dynare_estimation_1.m @@ -431,16 +431,18 @@ if (any(bayestopt_.pshape >0 ) && options_.mh_replic) || ... end end % runs MCMC - if options_.mh_replic - ana_deriv_old = options_.analytic_derivation; - options_.analytic_derivation = 0; + if options_.mh_replic || options_.load_mh_file posterior_sampler_options = options_.posterior_sampler_options.current_options; posterior_sampler_options.invhess = invhess; [posterior_sampler_options, options_] = check_posterior_sampler_options(posterior_sampler_options, options_); % store current options in global options_.posterior_sampler_options.current_options = posterior_sampler_options; - posterior_sampler(objective_function,posterior_sampler_options.proposal_distribution,xparam1,posterior_sampler_options,bounds,dataset_,dataset_info,options_,M_,estim_params_,bayestopt_,oo_); - options_.analytic_derivation = ana_deriv_old; + if options_.mh_replic + ana_deriv_old = options_.analytic_derivation; + options_.analytic_derivation = 0; + posterior_sampler(objective_function,posterior_sampler_options.proposal_distribution,xparam1,posterior_sampler_options,bounds,dataset_,dataset_info,options_,M_,estim_params_,bayestopt_,oo_); + options_.analytic_derivation = ana_deriv_old; + end end %% Here I discard first mh_drop percent of the draws: CutSample(M_, options_, estim_params_);