diff --git a/src/DynamicModel.cc b/src/DynamicModel.cc
index 76b6671eafd73236c60f58a08f4c9acf3bc096c1..858c708788bc6eeee213b14c686ae6d1f5767662 100644
--- a/src/DynamicModel.cc
+++ b/src/DynamicModel.cc
@@ -6542,3 +6542,15 @@ DynamicModel::substituteVarExpectation(const map<string, expr_t> &subst_table)
   for (auto &equation : equations)
     equation = dynamic_cast<BinaryOpNode *>(equation->substituteVarExpectation(subst_table));
 }
+
+void
+DynamicModel::checkNoRemainingPacExpectation() const
+{
+  for (size_t eq = 0; eq < equations.size(); eq++)
+    if (equations[eq]->containsPacExpectation())
+      {
+        cerr << "ERROR: in equation " << equation_tags.getTagValueByEqnAndKey(eq, "name")
+             << ", the pac_expectation operator references an unknown pac_model" << endl;
+        exit(EXIT_FAILURE);
+      }
+}
diff --git a/src/DynamicModel.hh b/src/DynamicModel.hh
index 3cb9941203e438748f291651e7c9285807121021..07c7b853adf48e000d1d1ed458759093972c4a1b 100644
--- a/src/DynamicModel.hh
+++ b/src/DynamicModel.hh
@@ -570,6 +570,10 @@ public:
   //! Fills eval context with values of model local variables and auxiliary variables
   void fillEvalContext(eval_context_t &eval_context) const;
 
+  /*! Checks that all pac_expectation operators have been substituted, error
+    out otherwise */
+  void checkNoRemainingPacExpectation() const;
+
   auto
   getStaticOnlyEquationsInfo() const
   {
diff --git a/src/ModFile.cc b/src/ModFile.cc
index 2e74af53cac5d43e7df51c523573e855322e2307..4d528ebbeb3bf5d047d95bdaa3f2151ec166d5dd 100644
--- a/src/ModFile.cc
+++ b/src/ModFile.cc
@@ -503,6 +503,7 @@ ModFile::transformPass(bool nostrict, bool stochastic, bool compute_xrefs, bool
                                          eqtag_and_lag, nonstationary, pms->growth);
         dynamic_model.substitutePacExpectation(pms->name);
       }
+  dynamic_model.checkNoRemainingPacExpectation();
 
   dynamic_model.addEquationsForVar();