From 16968cbf608d0c00c73f790b65f27001dd1056b1 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Adjemian=20=28Sedna=29?=
 <stephane.adjemian@univ-lemans.fr>
Date: Fri, 13 May 2011 12:32:23 +0200
Subject: [PATCH] Fixed bug with option cova_compute. (cherry picked from
 commit bd012c458f402ccd05659538714473c1d9ddda84)

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

diff --git a/matlab/dynare_estimation_1.m b/matlab/dynare_estimation_1.m
index 66462b2208..dff1119751 100644
--- a/matlab/dynare_estimation_1.m
+++ b/matlab/dynare_estimation_1.m
@@ -409,8 +409,6 @@ if ~isequal(options_.mode_compute,0) && ~options_.mh_posterior_mode_estimation
             else
                 hh = reshape(hessian('DsgeVarLikelihood',xparam1,options_.gstep,gend),nx,nx);
             end
-        else
-            nn = repmat(NaN,length(xparam1),length(xparam1))
         end
     end
     parameter_names = bayestopt_.name;
@@ -422,10 +420,10 @@ if ~isequal(options_.mode_compute,0) && ~options_.mh_posterior_mode_estimation
 end
 
 if options_.cova_compute == 0
-    hh = repmat(NaN,length(xparam1),length(xparam1));
+    hh = NaN(length(xparam1),length(xparam1));
 end
 
-if ~options_.mh_posterior_mode_estimation
+if ~options_.mh_posterior_mode_estimation && options_.cova_compute
     try
         chol(hh);
     catch
@@ -439,11 +437,11 @@ if ~options_.mh_posterior_mode_estimation
     end
 end
 
-if options_.mode_check == 1 && ~options_.mh_posterior_mode_estimation
+if options_.mode_check == 1 && ~options_.mh_posterior_mode_estimation && options_.cova_compute
     mode_check(xparam1,0,hh,gend,data,lb,ub,data_index,number_of_observations,no_more_missing_observations);
 end
 
-if ~options_.mh_posterior_mode_estimation
+if ~options_.mh_posterior_mode_estimation && options_.cova_compute
     invhess = inv(hh);
     stdh = sqrt(diag(invhess));
 else
@@ -457,6 +455,9 @@ else
     xparam1 = transpose(xparam1);
 end
 
+if ~options_.cova_compute
+    stdh = NaN(length(xparam1),1);
+end
 
 if any(bayestopt_.pshape > 0) && ~options_.mh_posterior_mode_estimation
     disp(' ')
-- 
GitLab