diff --git a/matlab/dynare_estimation_1.m b/matlab/dynare_estimation_1.m
index b821aeb93abd43d221bb8aa486996ca1f65a818c..9f0e890bf7570c39f446a67dcf96f5dcf3c7ebde 100644
--- a/matlab/dynare_estimation_1.m
+++ b/matlab/dynare_estimation_1.m
@@ -445,9 +445,11 @@ if options_.mode_check == 1 && ~options_.mh_posterior_mode_estimation && options
     end
 end
 
-if ~options_.mh_posterior_mode_estimation && options_.cova_compute
-    invhess = inv(hh);
-    stdh = sqrt(diag(invhess));
+if ~options_.mh_posterior_mode_estimation
+    if options_.cova_compute
+        invhess = inv(hh);
+        stdh = sqrt(diag(invhess));
+    end
 else
     variances = bayestopt_.p2.*bayestopt_.p2;
     idInf = isinf(variances);