From cc8a9fc7d21e917626bb8953058598ecc9f5a4e2 Mon Sep 17 00:00:00 2001
From: Michel Juillard <michel.juillard@mjui.fr>
Date: Thu, 1 Dec 2011 18:46:02 +0100
Subject: [PATCH] fixed bug in 2nd order approximation (cherrypicked by hand
 from commit bf3ecfd030c62e4d3b0133a77975f3820a6755eb)

---
 matlab/dr1.m | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/matlab/dr1.m b/matlab/dr1.m
index 67cdd6b19..ffb725115 100644
--- a/matlab/dr1.m
+++ b/matlab/dr1.m
@@ -599,7 +599,8 @@ E1 = [eye(npred); zeros(kp-npred,npred)];
 H = E1;
 hxx = dr.ghxx(nstatic+[1:npred],:);
 [junk,k2a,k2] = find(M_.lead_lag_incidence(M_.maximum_endo_lag+2,order_var));
-[err, B1] = sparse_hessian_times_B_kronecker_C(hessian(:,kh(k2,k2)),gu(k2a,:),options_.threads.kronecker.sparse_hessian_times_B_kronecker_C);
+[junk,k3a,k3] = find(M_.lead_lag_incidence(M_.maximum_endo_lag+2,:));
+[err, B1] = sparse_hessian_times_B_kronecker_C(hessian(:,kh(k3,k3)),gu(k3a,:),options_.threads.kronecker.sparse_hessian_times_B_kronecker_C);
 mexErrCheck('sparse_hessian_times_B_kronecker_C', err);
 RHS = RHS + jacobia_(:,k2)*guu(k2a,:)+B1;
 
-- 
GitLab