From 1e3e2f70a92a977fd1c5b05575a287867f53a35e Mon Sep 17 00:00:00 2001
From: Marco Ratto <marco.ratto@jrc.ec.europa.eu>
Date: Tue, 17 Jan 2017 19:23:27 +0100
Subject: [PATCH] set posterior sampler options when load_mh_file

---
 matlab/dynare_estimation_1.m | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/matlab/dynare_estimation_1.m b/matlab/dynare_estimation_1.m
index cd035c37fd..6693768cec 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_);
-- 
GitLab