From c6dc36536d1e8cae06671bd9c3674036c4d575e7 Mon Sep 17 00:00:00 2001
From: Johannes Pfeifer <jpfeifer@gmx.de>
Date: Wed, 10 Aug 2016 12:41:20 +0200
Subject: [PATCH] Add specification check of Ramsey policy to
 initial_estimation_checks.m

Related to #1173
---
 matlab/initial_estimation_checks.m | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/matlab/initial_estimation_checks.m b/matlab/initial_estimation_checks.m
index 3e6430a820..9673903095 100644
--- a/matlab/initial_estimation_checks.m
+++ b/matlab/initial_estimation_checks.m
@@ -110,7 +110,21 @@ if info
     fprintf('The prior density evaluated at the initial values is Inf for the following parameters: %s\n',BayesInfo.name{info,1})
     error('The initial value of the prior is -Inf')
 end
-    
+
+if DynareOptions.ramsey_policy
+    %test whether specification matches
+    inst_nbr = size(DynareOptions.instruments,1);
+    if inst_nbr~=0
+        orig_endo_aux_nbr = Model.orig_endo_nbr + min(find([Model.aux_vars.type] == 6)) - 1;
+        implied_inst_nbr = orig_endo_aux_nbr - Model.orig_eq_nbr;
+        if inst_nbr>implied_inst_nbr
+            error('You have specified more instruments than there are omitted equations')
+        elseif inst_nbr<implied_inst_nbr
+            error('You have specified fewer instruments than there are omitted equations')
+        end
+    end
+end
+
 % Evaluate the likelihood.
 ana_deriv = DynareOptions.analytic_derivation;
 DynareOptions.analytic_derivation=0;
-- 
GitLab