diff --git a/DynamicModel.cc b/DynamicModel.cc
index 56dcc0704dde7a49e8b5200e5456c20d539f962f..c56f15ec5a42a97f96558b550f61211176e1e8ea 100644
--- a/DynamicModel.cc
+++ b/DynamicModel.cc
@@ -3113,11 +3113,11 @@ DynamicModel::runTrendTest(const eval_context_t &eval_context)
 }
 
 void
-DynamicModel::computingPass(bool jacobianExo, bool hessian, bool thirdDerivatives, FileOutputType paramsDerivatives,
+DynamicModel::computingPass(bool jacobianExo, bool hessian, bool thirdDerivatives, int paramsDerivsOrder,
                             const eval_context_t &eval_context, bool no_tmp_terms, bool block, bool use_dll,
                             bool bytecode, bool compute_xrefs)
 {
-  assert(jacobianExo || !(hessian || thirdDerivatives || paramsDerivatives));
+  assert(jacobianExo || !(hessian || thirdDerivatives || paramsDerivsOrder));
 
   initializeVariablesAndEquations();
   
@@ -3148,10 +3148,10 @@ DynamicModel::computingPass(bool jacobianExo, bool hessian, bool thirdDerivative
       computeHessian(vars);
     }
 
-  if (paramsDerivatives != none)
+  if (paramsDerivsOrder > 0)
     {
       cout << " - derivatives of Jacobian/Hessian w.r. to parameters" << endl;
-      computeParamsDerivatives(paramsDerivatives);
+      computeParamsDerivatives(paramsDerivsOrder);
 
       if (!no_tmp_terms)
         computeParamsDerivativesTemporaryTerms();
diff --git a/DynamicModel.hh b/DynamicModel.hh
index 88f883cbbc94a3c0992605e9fb1149978bb0778f..9cef4cb023a2a1c4ee2ef82131ef33004233f577 100644
--- a/DynamicModel.hh
+++ b/DynamicModel.hh
@@ -208,11 +208,11 @@ public:
     \param jacobianExo whether derivatives w.r. to exo and exo_det should be in the Jacobian (derivatives w.r. to endo are always computed)
     \param hessian whether 2nd derivatives w.r. to exo, exo_det and endo should be computed (implies jacobianExo = true)
     \param thirdDerivatives whether 3rd derivatives w.r. to endo/exo/exo_det should be computed (implies jacobianExo = true)
-    \param paramsDerivatives whether 2nd derivatives w.r. to a pair (endo/exo/exo_det, parameter) should be computed (implies jacobianExo = true)
+    \param paramsDerivsOrder order of derivatives w.r. to a pair (endo/exo/exo_det, parameter) to be computed (>0 implies jacobianExo = true)
     \param eval_context evaluation context for normalization
     \param no_tmp_terms if true, no temporary terms will be computed in the dynamic files
   */
-  void computingPass(bool jacobianExo, bool hessian, bool thirdDerivatives, FileOutputType paramsDerivatives,
+  void computingPass(bool jacobianExo, bool hessian, bool thirdDerivatives, int paramsDerivsOrder,
                      const eval_context_t &eval_context, bool no_tmp_terms, bool block, bool use_dll, bool bytecode, bool compute_xrefs);
   //! Writes model initialization and lead/lag incidence matrix to output
   void writeOutput(ostream &output, const string &basename, bool block, bool byte_code, bool use_dll, int order, bool estimation_present, bool compute_xrefs, bool julia) const;
diff --git a/DynareMain.cc b/DynareMain.cc
index 4d6336f8df3d3c9ff33ed142a5b44c5229ab6045..6975ba0e92bbf7d120c51672933d08ec7c6bcf58 100644
--- a/DynareMain.cc
+++ b/DynareMain.cc
@@ -41,7 +41,7 @@ void main2(stringstream &in, string &basename, bool debug, bool clear_all, bool
            bool nograph, bool nointeractive, bool parallel, ConfigFile &config_file,
            WarningConsolidation &warnings_arg, bool nostrict, bool check_model_changes,
            bool minimal_workspace, bool compute_xrefs, FileOutputType output_mode,
-           LanguageOutputType lang, bool sec_order_param_deriv
+           LanguageOutputType lang, int params_derivs_order
 #if defined(_WIN32) || defined(__CYGWIN32__)
            , bool cygwin, bool msvc
 #endif
@@ -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]"
-       << " [no_2nd_order_params_derivs]"
+       << " [params_derivs_order=0|1|2]"
 #if defined(_WIN32) || defined(__CYGWIN32__)
        << " [cygwin] [msvc]"
 #endif
@@ -91,7 +91,7 @@ main(int argc, char **argv)
   bool no_line_macro = false;
   bool no_log = false;
   bool no_warn = false;
-  bool sec_order_param_deriv = true;
+  int params_derivs_order = 2;
   bool warn_uninit = false;
   bool console = false;
   bool nograph = false;
@@ -121,8 +121,16 @@ main(int argc, char **argv)
         debug = true;
       else if (!strcmp(argv[arg], "noclearall"))
         clear_all = false;
-      else if (!strcmp(argv[arg], "no_2nd_order_params_derivs"))
-        sec_order_param_deriv = false;
+      else if (strlen(argv[arg]) >= 19 && !strncmp(argv[arg], "params_derivs_order", 19))
+        {
+          if (strlen(argv[arg]) >= 22 || argv[arg][19] != '=' ||
+              !(argv[arg][20] == '0' || argv[arg][20] == '1' || argv[arg][20] == '2'))
+            {
+              cerr << "Incorrect syntax for params_derivs_order option" << endl;
+              usage();
+            }
+          params_derivs_order = stoi(string(argv[arg] + 20));
+        }
       else if (!strcmp(argv[arg], "onlyclearglobals"))
         {
           clear_all = false;
@@ -322,7 +330,7 @@ main(int argc, char **argv)
   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,
-        compute_xrefs, output_mode, language, sec_order_param_deriv
+        compute_xrefs, output_mode, language, params_derivs_order
 #if defined(_WIN32) || defined(__CYGWIN32__)
         , cygwin, msvc
 #endif
diff --git a/DynareMain2.cc b/DynareMain2.cc
index 386f939cda1ff08eb407768f7bcd7646e3b6f870..a023328e439f3fad2ce7e5b3791c95cf6d235782 100644
--- a/DynareMain2.cc
+++ b/DynareMain2.cc
@@ -30,7 +30,7 @@ main2(stringstream &in, string &basename, bool debug, bool clear_all, bool clear
       bool nograph, bool nointeractive, bool parallel, ConfigFile &config_file,
       WarningConsolidation &warnings, bool nostrict, bool check_model_changes,
       bool minimal_workspace, bool compute_xrefs, FileOutputType output_mode,
-      LanguageOutputType language, bool sec_order_param_deriv
+      LanguageOutputType language, int params_derivs_order
 #if defined(_WIN32) || defined(__CYGWIN32__)
       , bool cygwin, bool msvc
 #endif
@@ -51,7 +51,7 @@ main2(stringstream &in, string &basename, bool debug, bool clear_all, bool clear
   mod_file->evalAllExpressions(warn_uninit);
 
   // Do computations
-  mod_file->computingPass(no_tmp_terms, output_mode, compute_xrefs, sec_order_param_deriv);
+  mod_file->computingPass(no_tmp_terms, output_mode, compute_xrefs, params_derivs_order);
 
   // Write outputs
   if (output_mode != none)
diff --git a/ModFile.cc b/ModFile.cc
index 1a62e8004811663313adce46603d94cc29e71beb..c09f49ea1d0c94a8bda4f941a1b83693820afd62 100644
--- a/ModFile.cc
+++ b/ModFile.cc
@@ -469,7 +469,7 @@ ModFile::transformPass(bool nostrict)
 }
 
 void
-ModFile::computingPass(bool no_tmp_terms, FileOutputType output, bool compute_xrefs, bool sec_order_param_deriv)
+ModFile::computingPass(bool no_tmp_terms, FileOutputType output, bool compute_xrefs, int params_derivs_order)
 {
   // Mod file may have no equation (for example in a standalone BVAR estimation)
   if (dynamic_model.equation_number() > 0)
@@ -489,13 +489,11 @@ ModFile::computingPass(bool no_tmp_terms, FileOutputType output, bool compute_xr
 
 	  const bool static_hessian = mod_file_struct.identification_present
 	    || mod_file_struct.estimation_analytic_derivation;
-          FileOutputType paramsDerivatives = none;
-          if (mod_file_struct.estimation_analytic_derivation)
-            paramsDerivatives = third;
-          if (mod_file_struct.identification_present || !sec_order_param_deriv)
-            paramsDerivatives = first;
+          int paramsDerivsOrder = 0;
+          if (mod_file_struct.identification_present || mod_file_struct.estimation_analytic_derivation)
+            paramsDerivsOrder = params_derivs_order;
 	  static_model.computingPass(global_eval_context, no_tmp_terms, static_hessian,
-				     false, paramsDerivatives, block, byte_code);
+				     false, paramsDerivsOrder, block, byte_code);
 	}
       // Set things to compute for dynamic model
       if (mod_file_struct.perfect_foresight_solver_present || mod_file_struct.check_present
@@ -526,12 +524,10 @@ ModFile::computingPass(bool no_tmp_terms, FileOutputType output, bool compute_xr
 		  bool thirdDerivatives = mod_file_struct.order_option == 3 
 		    || mod_file_struct.estimation_analytic_derivation
 		    || output == third;
-                  FileOutputType paramsDerivatives = none;
-                  if (mod_file_struct.estimation_analytic_derivation)
-                    paramsDerivatives = third;
-                  if (mod_file_struct.identification_present || !sec_order_param_deriv)
-                    paramsDerivatives = first;
-		  dynamic_model.computingPass(true, hessian, thirdDerivatives, paramsDerivatives, global_eval_context, no_tmp_terms, block, use_dll, byte_code, compute_xrefs);
+                  int paramsDerivsOrder = 0;
+                  if (mod_file_struct.identification_present || mod_file_struct.estimation_analytic_derivation)
+                    paramsDerivsOrder = params_derivs_order;
+		  dynamic_model.computingPass(true, hessian, thirdDerivatives, paramsDerivsOrder, global_eval_context, no_tmp_terms, block, use_dll, byte_code, compute_xrefs);
 		}
 	    }
 	  else // No computing task requested, compute derivatives up to 2nd order by default
diff --git a/ModFile.hh b/ModFile.hh
index 8dcb91409c261e934ec1aad9204370ed7b2e3250..4635ac1c2ac77a925311558fe76dd87038271ff8 100644
--- a/ModFile.hh
+++ b/ModFile.hh
@@ -132,8 +132,8 @@ public:
   //! Execute computations
   /*! \param no_tmp_terms if true, no temporary terms will be computed in the static and dynamic files */
   /*! \param compute_xrefs if true, equation cross references will be computed */
-  /*! \param sec_order_param_deriv if true, compute second order param derivatives*/
-  void computingPass(bool no_tmp_terms, FileOutputType output, bool compute_xrefs, bool sec_order_param_deriv);
+  /*! \param params_derivs_order compute this order of derivs wrt parameters */
+  void computingPass(bool no_tmp_terms, FileOutputType output, bool compute_xrefs, int params_derivs_order);
   //! Writes Matlab/Octave output files
   /*!
     \param basename The base name used for writing output files. Should be the name of the mod file without its extension
diff --git a/ModelTree.cc b/ModelTree.cc
index 518bd3fde01bfdcbf83fb4acaf6214ed3faa527e..1fa26332bd651f013cc390fc242cd86e294a9c42 100644
--- a/ModelTree.cc
+++ b/ModelTree.cc
@@ -1657,9 +1657,9 @@ ModelTree::sparseHelper(int order, ostream &output, int row_nb, int col_nb, Expr
 }
 
 void
-ModelTree::computeParamsDerivatives(FileOutputType paramsDerivatives)
+ModelTree::computeParamsDerivatives(int paramsDerivsOrder)
 {
-  if (!(paramsDerivatives == first || paramsDerivatives == second || paramsDerivatives == third))
+  if (!(paramsDerivsOrder == 1 || paramsDerivsOrder == 2))
     return;
   set<int> deriv_id_set;
   addAllParamDerivId(deriv_id_set);
@@ -1677,7 +1677,7 @@ ModelTree::computeParamsDerivatives(FileOutputType paramsDerivatives)
           residuals_params_derivatives[make_pair(eq, param)] = d1;
         }
 
-      if (paramsDerivatives == second || paramsDerivatives == third)
+      if (paramsDerivsOrder == 2)
         for (first_derivatives_t::const_iterator it2 = residuals_params_derivatives.begin();
              it2 != residuals_params_derivatives.end(); it2++)
           {
@@ -1704,35 +1704,36 @@ ModelTree::computeParamsDerivatives(FileOutputType paramsDerivatives)
           jacobian_params_derivatives[make_pair(eq, make_pair(var, param))] = d2;
         }
 
-      if (paramsDerivatives == second || paramsDerivatives == third)
-        for (second_derivatives_t::const_iterator it2 = jacobian_params_derivatives.begin();
-             it2 != jacobian_params_derivatives.end(); it2++)
-          {
-            int eq = it2->first.first;
-            int var = it2->first.second.first;
-            int param1 = it2->first.second.second;
-            expr_t d1 = it2->second;
-
-            expr_t d2 = d1->getDerivative(param);
-            if (d2 == Zero)
-              continue;
-            jacobian_params_second_derivatives[make_pair(eq, make_pair(var, make_pair(param1, param)))] = d2;
-          }
-
-      if (paramsDerivatives == third)
-        for (second_derivatives_t::const_iterator it2 = second_derivatives.begin();
-             it2 != second_derivatives.end(); it2++)
-          {
-            int eq = it2->first.first;
-            int var1 = it2->first.second.first;
-            int var2 = it2->first.second.second;
-            expr_t d1 = it2->second;
+      if (paramsDerivsOrder == 2)
+        {
+          for (second_derivatives_t::const_iterator it2 = jacobian_params_derivatives.begin();
+               it2 != jacobian_params_derivatives.end(); it2++)
+            {
+              int eq = it2->first.first;
+              int var = it2->first.second.first;
+              int param1 = it2->first.second.second;
+              expr_t d1 = it2->second;
+
+              expr_t d2 = d1->getDerivative(param);
+              if (d2 == Zero)
+                continue;
+              jacobian_params_second_derivatives[make_pair(eq, make_pair(var, make_pair(param1, param)))] = d2;
+            }
 
-            expr_t d2 = d1->getDerivative(param);
-            if (d2 == Zero)
-              continue;
-            hessian_params_derivatives[make_pair(eq, make_pair(var1, make_pair(var2, param)))] = d2;
-          }
+          for (second_derivatives_t::const_iterator it2 = second_derivatives.begin();
+               it2 != second_derivatives.end(); it2++)
+            {
+              int eq = it2->first.first;
+              int var1 = it2->first.second.first;
+              int var2 = it2->first.second.second;
+              expr_t d1 = it2->second;
+
+              expr_t d2 = d1->getDerivative(param);
+              if (d2 == Zero)
+                continue;
+              hessian_params_derivatives[make_pair(eq, make_pair(var1, make_pair(var2, param)))] = d2;
+            }
+        }
     }
 }
 
diff --git a/ModelTree.hh b/ModelTree.hh
index 41f30d3b3c1700908d8c7756f87b4f90613bedf4..4db8fb8673999f8ecf1afbb7df371d9f5958067e 100644
--- a/ModelTree.hh
+++ b/ModelTree.hh
@@ -177,7 +177,7 @@ protected:
   /*! \param vars the derivation IDs w.r. to which derive the 2nd derivatives */
   void computeThirdDerivatives(const set<int> &vars);
   //! Computes derivatives of the Jacobian and Hessian w.r. to parameters
-  void computeParamsDerivatives(FileOutputType paramsDerivatives);
+  void computeParamsDerivatives(int paramsDerivsOrder);
   //! Write derivative of an equation w.r. to a variable
   void writeDerivative(ostream &output, int eq, int symb_id, int lag, ExprNodeOutputType output_type, const temporary_terms_t &temporary_terms) const;
   //! Computes temporary terms (for all equations and derivatives)
diff --git a/StaticModel.cc b/StaticModel.cc
index a3b42f56250cd563b3cabab26eca4292b323b149..3f1ec680568b81fb4ea2fbca0dcb48a42039d5a5 100644
--- a/StaticModel.cc
+++ b/StaticModel.cc
@@ -1047,7 +1047,7 @@ StaticModel::collect_first_order_derivatives_endogenous()
 }
 
 void
-StaticModel::computingPass(const eval_context_t &eval_context, bool no_tmp_terms, bool hessian, bool thirdDerivatives, FileOutputType paramsDerivatives, bool block, bool bytecode)
+StaticModel::computingPass(const eval_context_t &eval_context, bool no_tmp_terms, bool hessian, bool thirdDerivatives, int paramsDerivsOrder, bool block, bool bytecode)
 {
   initializeVariablesAndEquations();
 
@@ -1095,10 +1095,10 @@ StaticModel::computingPass(const eval_context_t &eval_context, bool no_tmp_terms
       computeThirdDerivatives(vars);
     }
 
-  if (paramsDerivatives != none)
+  if (paramsDerivsOrder > 0)
     {
       cout << " - derivatives of Jacobian/Hessian w.r. to parameters" << endl;
-      computeParamsDerivatives(paramsDerivatives);
+      computeParamsDerivatives(paramsDerivsOrder);
 
       if (!no_tmp_terms)
         computeParamsDerivativesTemporaryTerms();
diff --git a/StaticModel.hh b/StaticModel.hh
index d8ec97900bd11037b6d8bfc0ff3f923ee2ea6eef..21609adabecfead8507202f5ef62472b93c08942 100644
--- a/StaticModel.hh
+++ b/StaticModel.hh
@@ -162,9 +162,9 @@ public:
     \param eval_context evaluation context for normalization
     \param no_tmp_terms if true, no temporary terms will be computed in the static files
     \param hessian whether 2nd derivatives w.r. to exo, exo_det and endo should be computed
-    \param paramsDerivatives whether 2nd derivatives w.r. to a pair (endo/exo/exo_det, parameter) should be computed
+    \param paramsDerivsOrder order of derivatives w.r. to a pair (endo/exo/exo_det, parameter) to be computed
   */
-  void computingPass(const eval_context_t &eval_context, bool no_tmp_terms, bool hessian, bool thirdDerivatices, FileOutputType paramsDerivatives, bool block, bool bytecode);
+  void computingPass(const eval_context_t &eval_context, bool no_tmp_terms, bool hessian, bool thirdDerivatices, int paramsDerivsOrder, bool block, bool bytecode);
 
   //! Adds informations for simulation in a binary file for a block decomposed model
   void Write_Inf_To_Bin_File_Block(const string &static_basename, const string &bin_basename, const int &num,