diff --git a/ModFile.cc b/ModFile.cc
index 7f31e86ff05e89a1a78db8aa18c53434d5be6477..27299deac983001174e56b479f11879753001432 100644
--- a/ModFile.cc
+++ b/ModFile.cc
@@ -585,9 +585,6 @@ ModFile::writeOutputFiles(const string &basename, bool clear_all, bool no_log, b
               << "M_.Correlation_matrix = eye(" << symbol_table.exo_nbr() << ", "
               << symbol_table.exo_nbr() << ");" << endl;
 
-  // Initialize M_.det_shocks
-  mOutputFile << "M_.det_shocks = [];" << endl;
-
   if (mod_file_struct.calibrated_measurement_errors)
     mOutputFile << "M_.H = zeros(" << symbol_table.observedVariablesNbr() << ", "
                 << symbol_table.observedVariablesNbr() << ");" << endl
@@ -597,6 +594,9 @@ ModFile::writeOutputFiles(const string &basename, bool clear_all, bool no_log, b
     mOutputFile << "M_.H = 0;" << endl
                 << "M_.Correlation_matrix_ME = 1;" << endl;
 
+  // Initialize M_.det_shocks
+  mOutputFile << "M_.det_shocks = [];" << endl;
+
   if (linear == 1)
     mOutputFile << "options_.linear = 1;" << endl;