diff --git a/src/ComputingTasks.cc b/src/ComputingTasks.cc
index c332510d2f519dc3121d8db055aeae3ee01653e7..73fc5ca896393c2207bb643f1a3f088d824e32c0 100644
--- a/src/ComputingTasks.cc
+++ b/src/ComputingTasks.cc
@@ -1361,11 +1361,15 @@ EstimatedParamsStatement::checkPass(ModFileStructure &mod_file_struct, WarningCo
 void
 EstimatedParamsStatement::writeOutput(ostream &output, const string &basename, bool minimal_workspace) const
 {
-  output << "estim_params_.var_exo = zeros(0, 10);" << endl
-         << "estim_params_.var_endo = zeros(0, 10);" << endl
-         << "estim_params_.corrx = zeros(0, 11);" << endl
-         << "estim_params_.corrn = zeros(0, 11);" << endl
-         << "estim_params_.param_vals = zeros(0, 10);" << endl;
+  /* Multiple estimated_params statements are allowed, so make sure we don’t
+     overwrite previous ones. */
+  output << "if isempty(estim_params_)" << endl
+         << "    estim_params_.var_exo = zeros(0, 10);" << endl
+         << "    estim_params_.var_endo = zeros(0, 10);" << endl
+         << "    estim_params_.corrx = zeros(0, 11);" << endl
+         << "    estim_params_.corrn = zeros(0, 11);" << endl
+         << "    estim_params_.param_vals = zeros(0, 10);" << endl
+         << "end" << endl;
 
   for (const auto &it : estim_params_list)
     {