From f51a57374ade0e6092a0b9ac9d475a9361058849 Mon Sep 17 00:00:00 2001
From: Johannes Pfeifer <jpfeifer@gmx.de>
Date: Tue, 1 Jun 2021 11:23:07 +0200
Subject: [PATCH] mh_tune_jscale: fix display of stepsize and provide warning
 if no updating can occur.

---
 matlab/calibrate_mh_scale_parameter.m | 2 +-
 matlab/initial_estimation_checks.m    | 4 ++++
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/matlab/calibrate_mh_scale_parameter.m b/matlab/calibrate_mh_scale_parameter.m
index b1e7feb992..4108910597 100644
--- a/matlab/calibrate_mh_scale_parameter.m
+++ b/matlab/calibrate_mh_scale_parameter.m
@@ -73,7 +73,7 @@ while j<=options.maxiter
     prtfrc = j/options.maxiter;
     % Update the waitbar
     if ~mod(j, 10)
-        dyn_waitbar(prtfrc, hh, sprintf('Acceptance ratio [during last 500]: %f [%f]', isux/j, jsux/jj));
+        dyn_waitbar(prtfrc, hh, sprintf('Acceptance ratio [during last %u]: %f [%f]', options.stepsize, isux/j, jsux/jj));
     end
     % Adjust the value of the scale parameter.
     if ~mod(j, options.stepsize)
diff --git a/matlab/initial_estimation_checks.m b/matlab/initial_estimation_checks.m
index fa4acfcde8..36096b8789 100644
--- a/matlab/initial_estimation_checks.m
+++ b/matlab/initial_estimation_checks.m
@@ -290,6 +290,10 @@ if ~isequal(DynareOptions.mode_compute,11)
     disp(['Initial value of the log posterior (or likelihood): ' num2str(-fval)]);
 end
 
+if DynareOptions.mh_tune_jscale.status && (DynareOptions.mh_tune_jscale.maxiter<DynareOptions.mh_tune_jscale.stepsize)
+    warning('You specified mh_tune_jscale, but the maximum number of iterations is smaller than the step size. No update will take place.')
+end
+
 function evaluate_expression(expression,M_,oo_)
 % function evaluate_expression(expression,M_,oo_)
 %evaluates expressions relying on M_ and oo_ having their original names
-- 
GitLab