diff --git a/DynareMain.cc b/DynareMain.cc
index bee2ce3a3c9b88a476784ca55d38bc44bd98cb61..8176d6f99a5435e336332157d33f6b1b94ca186f 100644
--- a/DynareMain.cc
+++ b/DynareMain.cc
@@ -39,7 +39,7 @@
 void main2(stringstream &in, string &basename, bool debug, bool clear_all, bool clear_global,
            bool no_tmp_terms, bool no_log, bool no_warn, bool warn_uninit, bool console,
            bool nograph, bool nointeractive, bool parallel, ConfigFile &config_file,
-           WarningConsolidation &warnings_arg, bool nostrict, bool check_model_changes,
+           WarningConsolidation &warnings_arg, bool nostrict, bool stochastic, bool check_model_changes,
            bool minimal_workspace, bool compute_xrefs, FileOutputType output_mode,
            LanguageOutputType lang, int params_derivs_order
 #if defined(_WIN32) || defined(__CYGWIN32__) || defined(__MINGW32__)
@@ -57,7 +57,7 @@ usage()
 {
   cerr << "Dynare usage: dynare mod_file [debug] [noclearall] [onlyclearglobals] [savemacro[=macro_file]] [onlymacro] [nolinemacro] [notmpterms] [nolog] [warn_uninit]"
        << " [console] [nograph] [nointeractive] [parallel[=cluster_name]] [conffile=parallel_config_path_and_filename] [parallel_slave_open_mode] [parallel_test]"
-       << " [-D<variable>[=<value>]] [-I/path] [nostrict] [fast] [minimal_workspace] [compute_xrefs] [output=dynamic|first|second|third] [language=C|C++|julia]"
+       << " [-D<variable>[=<value>]] [-I/path] [nostrict] [stochastic] [fast] [minimal_workspace] [compute_xrefs] [output=dynamic|first|second|third] [language=C|C++|julia]"
        << " [params_derivs_order=0|1|2]"
 #if defined(_WIN32) || defined(__CYGWIN32__) || defined(__MINGW32__)
        << " [cygwin] [msvc] [mingw]"
@@ -109,6 +109,7 @@ main(int argc, char **argv)
   bool parallel_slave_open_mode = false;
   bool parallel_test = false;
   bool nostrict = false;
+  bool stochastic = false;
   bool check_model_changes = false;
   bool minimal_workspace = false;
   bool compute_xrefs = false;
@@ -197,6 +198,8 @@ main(int argc, char **argv)
         parallel_test = true;
       else if (!strcmp(argv[arg], "nostrict"))
         nostrict = true;
+      else if (!strcmp(argv[arg], "stochastic"))
+        stochastic = true;
       else if (!strcmp(argv[arg], "fast"))
         check_model_changes = true;
       else if (!strcmp(argv[arg], "minimal_workspace"))
@@ -365,7 +368,7 @@ main(int argc, char **argv)
   // Do the rest
   main2(macro_output, basename, debug, clear_all, clear_global,
         no_tmp_terms, no_log, no_warn, warn_uninit, console, nograph, nointeractive,
-        parallel, config_file, warnings, nostrict, check_model_changes, minimal_workspace,
+        parallel, config_file, warnings, nostrict, stochastic, check_model_changes, minimal_workspace,
         compute_xrefs, output_mode, language, params_derivs_order
 #if defined(_WIN32) || defined(__CYGWIN32__) || defined(__MINGW32__)
         , cygwin, msvc, mingw
diff --git a/DynareMain2.cc b/DynareMain2.cc
index e0a9e5392912400927aed3d722131639b7e808d1..6f0e113917835db3c9d1263904e38398ae7db017 100644
--- a/DynareMain2.cc
+++ b/DynareMain2.cc
@@ -28,7 +28,7 @@ void
 main2(stringstream &in, string &basename, bool debug, bool clear_all, bool clear_global,
       bool no_tmp_terms, bool no_log, bool no_warn, bool warn_uninit, bool console,
       bool nograph, bool nointeractive, bool parallel, ConfigFile &config_file,
-      WarningConsolidation &warnings, bool nostrict, bool check_model_changes,
+      WarningConsolidation &warnings, bool nostrict, bool stochastic, bool check_model_changes,
       bool minimal_workspace, bool compute_xrefs, FileOutputType output_mode,
       LanguageOutputType language, int params_derivs_order
 #if defined(_WIN32) || defined(__CYGWIN32__) || defined(__MINGW32__)
@@ -45,12 +45,12 @@ main2(stringstream &in, string &basename, bool debug, bool clear_all, bool clear
     mod_file->writeJsonOutput(basename, json, json_output_mode, onlyjson);
 
   // Run checking pass
-  mod_file->checkPass(nostrict);
+  mod_file->checkPass(nostrict, stochastic);
   if (json == checkpass)
     mod_file->writeJsonOutput(basename, json, json_output_mode, onlyjson);
 
   // Perform transformations on the model (creation of auxiliary vars and equations)
-  mod_file->transformPass(nostrict, compute_xrefs || json == transformpass);
+  mod_file->transformPass(nostrict, stochastic, compute_xrefs || json == transformpass);
   if (json == transformpass)
     mod_file->writeJsonOutput(basename, json, json_output_mode, onlyjson);
 
diff --git a/ModFile.cc b/ModFile.cc
index 6fea425e5d050a44a6895bb41479969b4d886383..3af3faa58495b2e44cffa89dd7aa7dbfb4645681 100644
--- a/ModFile.cc
+++ b/ModFile.cc
@@ -107,7 +107,7 @@ ModFile::addStatementAtFront(Statement *st)
 }
 
 void
-ModFile::checkPass(bool nostrict)
+ModFile::checkPass(bool nostrict, bool stochastic)
 {
   for (vector<Statement *>::iterator it = statements.begin();
        it != statements.end(); it++)
@@ -136,7 +136,8 @@ ModFile::checkPass(bool nostrict)
     || mod_file_struct.osr_present
     || mod_file_struct.ramsey_policy_present
     || mod_file_struct.discretionary_policy_present
-    || mod_file_struct.calib_smoother_present;
+    || mod_file_struct.calib_smoother_present
+    || stochastic;
 
   // Allow empty model only when doing a standalone BVAR estimation
   if (dynamic_model.equation_number() == 0
@@ -339,7 +340,7 @@ ModFile::checkPass(bool nostrict)
 }
 
 void
-ModFile::transformPass(bool nostrict, bool compute_xrefs)
+ModFile::transformPass(bool nostrict, bool stochastic, bool compute_xrefs)
 {
   // Save the original model (must be done before any model transformations by preprocessor)
   dynamic_model.setLeadsLagsOrig();
@@ -398,7 +399,8 @@ ModFile::transformPass(bool nostrict, bool compute_xrefs)
       || mod_file_struct.osr_present
       || mod_file_struct.ramsey_policy_present
       || mod_file_struct.discretionary_policy_present
-      || mod_file_struct.calib_smoother_present)
+      || mod_file_struct.calib_smoother_present
+      || stochastic )
     {
       // In stochastic models, create auxiliary vars for leads and lags greater than 2, on both endos and exos
       dynamic_model.substituteEndoLeadGreaterThanTwo(false);
diff --git a/ModFile.hh b/ModFile.hh
index 7744d92815196d9aefa75a267f707391a5b21ccf..216542cbfa14c212734e94a2dc37fbf20438c945 100644
--- a/ModFile.hh
+++ b/ModFile.hh
@@ -131,10 +131,10 @@ public:
   void evalAllExpressions(bool warn_uninit);
   //! Do some checking and fills mod_file_struct
   /*! \todo add check for number of equations and endogenous if ramsey_policy is present */
-  void checkPass(bool nostrict);
+  void checkPass(bool nostrict, bool stochastic);
   //! Perform some transformations on the model (creation of auxiliary vars and equations)
   /*! \param compute_xrefs if true, equation cross references will be computed */
-  void transformPass(bool nostrict, bool compute_xrefs);
+  void transformPass(bool nostrict, bool stochastic, bool compute_xrefs);
   //! Execute computations
   /*! \param no_tmp_terms if true, no temporary terms will be computed in the static and dynamic files */
   /*! \param params_derivs_order compute this order of derivs wrt parameters */