From d9fb19e4794a4d37ce1a1b05998f6528a466c762 Mon Sep 17 00:00:00 2001
From: Johannes Pfeifer <jpfeifer@gmx.de>
Date: Sun, 12 May 2013 13:27:55 +0200
Subject: [PATCH] Make error message if mode violated prior more explicit

---
 matlab/dynare_estimation_1.m | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/matlab/dynare_estimation_1.m b/matlab/dynare_estimation_1.m
index 7efbd29c99..25c596dd02 100644
--- a/matlab/dynare_estimation_1.m
+++ b/matlab/dynare_estimation_1.m
@@ -927,9 +927,12 @@ if (any(bayestopt_.pshape  >0 ) && options_.mh_replic) || ...
     bayestopt_.lb = bounds(:,1);
     bayestopt_.ub = bounds(:,2);
     if any(xparam1 < bounds(:,1)) || any(xparam1 > bounds(:,2))
-        find(xparam1 < bounds(:,1))
-        find(xparam1 > bounds(:,2))
-        error('Mode values are outside prior bounds. Reduce prior_trunc.')
+        outside_bound_vars=bayestopt_.name([find(xparam1 < bounds(:,1)); find(xparam1 > bounds(:,2))],:);
+        disp_string=[outside_bound_vars{1,:}];
+        for ii=2:size(outside_bound_vars,1)
+            disp_string=[disp_string,', ',outside_bound_vars{ii,:}];
+        end
+        error(['Mode value(s) of ', disp_string ,' are outside parameter bounds. Potentially, you should set prior_trunc=0.'])
     end
     % runs MCMC
     if options_.mh_replic
-- 
GitLab