diff --git a/ComputingTasks.cc b/ComputingTasks.cc
index f2e35bdcc66e4fec101247d635022ee95ec5d80c..e26c625eeb4cad8bc55f18d7ecc84eab781b3c34 100644
--- a/ComputingTasks.cc
+++ b/ComputingTasks.cc
@@ -358,7 +358,16 @@ VarModelStatement::writeOutput(ostream &output, const string &basename, bool min
   if (!symbol_list.empty())
     symbol_list.writeOutput("options_.var.var_list_", output);
 
-  output << "options_.var.lhs = [";
+  output << "options_.var.eqn = [";
+  for (vector<int>::const_iterator it = eqnumber.begin();
+       it != eqnumber.end(); it++)
+    {
+      if (it != eqnumber.begin())
+        output << " ";
+      output << *it + 1;
+    }
+  output << "];" << endl
+         << "options_.var.lhs = [";
   for (vector<int>::const_iterator it = lhs.begin();
        it != lhs.end(); it++)
     {
diff --git a/DataTree.cc b/DataTree.cc
index 0b3b4b220a0afcfb3ead22aedf04d9c14f811f20..493137224671443cf3ff7048a72c2e65dfd422f7 100644
--- a/DataTree.cc
+++ b/DataTree.cc
@@ -521,14 +521,14 @@ DataTree::AddVarExpectation(const int symb_id, const int forecast_horizon, const
 }
 
 expr_t
-DataTree::AddPacExpectation(const string &model_name, const int discount_id, const int growth_id)
+DataTree::AddPacExpectation(const string &model_name, const string &var_model_name, const int discount_id, const int growth_id)
 {
   pac_expectation_node_map_t::iterator it =
-    pac_expectation_node_map.find(make_pair(model_name, make_pair(discount_id, growth_id)));
+    pac_expectation_node_map.find(make_pair(model_name, make_pair(var_model_name, make_pair(discount_id, growth_id))));
   if (it != pac_expectation_node_map.end())
     return it->second;
 
-  return new PacExpectationNode(*this, model_name, discount_id, growth_id);
+  return new PacExpectationNode(*this, model_name, var_model_name, discount_id, growth_id);
 }
 
 expr_t
diff --git a/DataTree.hh b/DataTree.hh
index 9dd42fb4eb128592fc1f4837b936ad3f0efd6aee..e55de76c5b9ddacb6a8c12c034ff9cf8ebd1e7e2 100644
--- a/DataTree.hh
+++ b/DataTree.hh
@@ -82,7 +82,7 @@ protected:
   var_expectation_node_map_t var_expectation_node_map;
 
   // (model_name, (discount, growth)) -> PacExpectationNode
-  typedef map<pair<string, pair<int, int> >, PacExpectationNode *> pac_expectation_node_map_t;
+  typedef map<pair<string, pair<string, pair<int, int> > >, PacExpectationNode *> pac_expectation_node_map_t;
   pac_expectation_node_map_t pac_expectation_node_map;
 
   // ((arguments, deriv_idx), symb_id) -> FirstDerivExternalFunctionNode
@@ -232,7 +232,7 @@ public:
   //! Adds "var_expectation(arg1, arg2, model_name=arg3)" to model tree
   expr_t AddVarExpectation(const int symb_id, const int forecast_horizon, const string &model_name);
   //! Adds pac_expectation command to model tree
-  expr_t AddPacExpectation(const string &model_name, const int discount_id, const int growth_id);
+  expr_t AddPacExpectation(const string &model_name, const string &var_model_name, const int discount_id, const int growth_id);
   //! Adds a model local variable with its value
   void AddLocalVariable(int symb_id, expr_t value) throw (LocalVariableException);
   //! Adds an external function node
diff --git a/DynareBison.yy b/DynareBison.yy
index 75113c9254cce3589a7497a058e9446f7c6fcb08..e9aa4509c0910d4cc0ba12dc3a289c29cc3b43ff 100644
--- a/DynareBison.yy
+++ b/DynareBison.yy
@@ -115,7 +115,7 @@ class ParsingDriver;
 %token NONLINEAR_FILTER_INITIALIZATION FILTER_ALGORITHM PROPOSAL_APPROXIMATION CUBATURE UNSCENTED MONTECARLO DISTRIBUTION_APPROXIMATION
 %token <string_val> NAME
 %token USE_PENALIZED_OBJECTIVE_FOR_HESSIAN INIT_STATE RESCALE_PREDICTION_ERROR_COVARIANCE GENERATE_IRFS
-%token NAN_CONSTANT NO_STATIC NOBS NOCONSTANT NODISPLAY NOCORR NODIAGNOSTIC NOFUNCTIONS NO_HOMOTOPY
+%token NAN_CONSTANT NO_STATIC NOBS NOCONSTANT NODISPLAY NOCORR NODIAGNOSTIC NOFUNCTIONS NO_HOMOTOPY VAR_MODEL_NAME
 %token NOGRAPH POSTERIOR_NOGRAPH POSTERIOR_GRAPH NOMOMENTS NOPRINT NORMAL_PDF SAVE_DRAWS MODEL_NAME STDERR_MULTIPLES DIAGONAL_ONLY
 %token OBSERVATION_TRENDS OPTIM OPTIM_WEIGHTS ORDER OSR OSR_PARAMS MAX_DIM_COVA_GROUP ADVANCED OUTFILE OUTVARS OVERWRITE DISCOUNT
 %token PARALLEL_LOCAL_FILES PARAMETERS PARAMETER_SET PARTIAL_INFORMATION PERIODS PERIOD PLANNER_OBJECTIVE PLOT_CONDITIONAL_FORECAST PLOT_PRIORS PREFILTER PRESAMPLE
@@ -973,7 +973,9 @@ pac_expectation_options_list : pac_expectation_options_list COMMA pac_expectatio
                              | pac_expectation_options
                              ;
 
-pac_expectation_options : MODEL_NAME EQUAL QUOTED_STRING
+pac_expectation_options : VAR_MODEL_NAME EQUAL NAME
+                          { driver.add_pac_expectation_var_model_name($3); }
+                        | MODEL_NAME EQUAL NAME
                           { driver.add_pac_expectation_model_name($3); }
                         | DISCOUNT EQUAL symbol
                           { driver.add_pac_expectation_discount($3); }
diff --git a/DynareFlex.ll b/DynareFlex.ll
index 6248ed6aa5fe03ec45afab1ecd043a448b4bf928..8aa307dab0f9c35f9094550aa6f6327fe12f2af7 100644
--- a/DynareFlex.ll
+++ b/DynareFlex.ll
@@ -342,6 +342,7 @@ DATE -?[0-9]+([YyAa]|[Mm]([1-9]|1[0-2])|[Qq][1-4]|[Ww]([1-9]{1}|[1-4][0-9]|5[0-2
 <DYNARE_STATEMENT>optim		{return token::OPTIM;}
 <DYNARE_STATEMENT>periods	{return token::PERIODS;}
 <DYNARE_STATEMENT,DYNARE_BLOCK>model_name	{return token::MODEL_NAME;}
+<DYNARE_BLOCK>var_model_name    {return token::VAR_MODEL_NAME;}
 <DYNARE_STATEMENT>endogenous_terminal_period 	{return token::ENDOGENOUS_TERMINAL_PERIOD;}
 <DYNARE_STATEMENT>sub_draws	{return token::SUB_DRAWS;}
 <DYNARE_STATEMENT>minimal_solving_periods {return token::MINIMAL_SOLVING_PERIODS;}
diff --git a/ExprNode.cc b/ExprNode.cc
index 655c07234f1fbde1c94e02565241d93dfb3348b0..b3dd523e9993ca4d8e8fc8c430a1c0972b8eedeb 100644
--- a/ExprNode.cc
+++ b/ExprNode.cc
@@ -7209,16 +7209,18 @@ VarExpectationNode::writeJsonOutput(ostream &output,
 
 PacExpectationNode::PacExpectationNode(DataTree &datatree_arg,
                                        const string &model_name_arg,
+                                       const string &var_model_name_arg,
                                        const int discount_symb_id_arg,
                                        const int growth_symb_id_arg) :
   ExprNode(datatree_arg),
   model_name(model_name_arg),
+  var_model_name(var_model_name_arg),
   discount_symb_id(discount_symb_id_arg),
   growth_symb_id(growth_symb_id_arg),
   stationary_vars_present(false),
   nonstationary_vars_present(false)
 {
-  datatree.pac_expectation_node_map[make_pair(model_name, make_pair(discount_symb_id, growth_symb_id))] = this;
+  datatree.pac_expectation_node_map[make_pair(model_name, make_pair(var_model_name, make_pair(discount_symb_id, growth_symb_id)))] = this;
 }
 
 void
@@ -7246,13 +7248,13 @@ PacExpectationNode::computeTemporaryTerms(map<expr_t, int> &reference_count,
 expr_t
 PacExpectationNode::toStatic(DataTree &static_datatree) const
 {
-  return static_datatree.AddPacExpectation(string(model_name), discount_symb_id, growth_symb_id);
+  return static_datatree.AddPacExpectation(string(model_name), string(var_model_name), discount_symb_id, growth_symb_id);
 }
 
 expr_t
 PacExpectationNode::cloneDynamic(DataTree &dynamic_datatree) const
 {
-  return dynamic_datatree.AddPacExpectation(string(model_name), discount_symb_id, growth_symb_id);
+  return dynamic_datatree.AddPacExpectation(string(model_name), string(var_model_name), discount_symb_id, growth_symb_id);
 }
 
 void
@@ -7265,12 +7267,13 @@ PacExpectationNode::writeOutput(ostream &output, ExprNodeOutputType output_type,
   if (IS_LATEX(output_type))
     {
       output << "PAC_EXPECTATION" << LEFT_PAR(output_type) << model_name << ", "
-             << discount_symb_id  << ", " << growth_symb_id;
+             << var_model_name << ", " << discount_symb_id  << ", " << growth_symb_id;
       output << RIGHT_PAR(output_type);
       return;
     }
 
-  output << "M_.pac_expectation." << model_name << ".discount_param_index = "
+  output <<"M_.pac_expectation." << model_name << ".var_model_name = '" << var_model_name << "';" << endl
+         << "M_.pac_expectation." << model_name << ".discount_param_index = "
          << datatree.symbol_table.getTypeSpecificID(discount_symb_id) + 1 << ";" << endl
          << "M_.pac_expectation." << model_name << ".growth_name = '"
          << datatree.symbol_table.getName(growth_symb_id) << "';" << endl
diff --git a/ExprNode.hh b/ExprNode.hh
index 156df34af11a4ccef5d0991e34146b96ef448afb..a8d417a02d20b4e80b17c097b2a03982030d0ea4 100644
--- a/ExprNode.hh
+++ b/ExprNode.hh
@@ -1244,14 +1244,14 @@ public:
 class PacExpectationNode : public ExprNode
 {
 private:
-  const string model_name;
+  const string model_name, var_model_name;
   const int discount_symb_id, growth_symb_id;
   bool stationary_vars_present, nonstationary_vars_present;
   map<int, set<int > > z_vec; // lag -> set< symb_id > (all vars that appear at a given lag)
   vector<int> h0_indices, h1_indices;
   int growth_param_index;
 public:
-  PacExpectationNode(DataTree &datatree_arg, const string &model_name,
+  PacExpectationNode(DataTree &datatree_arg, const string &model_name, const string &var_model_name,
                      const int discount_arg, const int growth_arg);
   virtual void computeTemporaryTerms(map<expr_t, pair<int, NodeTreeReference> > &reference_count,
                                      map<NodeTreeReference, temporary_terms_t> &temp_terms_map,
diff --git a/ParsingDriver.cc b/ParsingDriver.cc
index 47eeba3c7e6c10658704578543314dccf1cc1642..bb12cada5655ba97ad6de63571a41d6393087757 100644
--- a/ParsingDriver.cc
+++ b/ParsingDriver.cc
@@ -2678,6 +2678,9 @@ ParsingDriver::add_pac_expectation()
   if (pac_expectation_model_name.empty())
     error("pac_expectation: you must pass the model_name option");
 
+  if (pac_expectation_var_model_name.empty())
+    error("pac_expectation: you must pass the var_model_name option");
+
   if (pac_expectation_discount.empty())
     error("pac_expectation: you must pass the discount option");
 
@@ -2691,6 +2694,7 @@ ParsingDriver::add_pac_expectation()
     mod_file->symbol_table.getID(pac_expectation_growth);
 
   expr_t pac_exp_node = data_tree->AddPacExpectation(pac_expectation_model_name,
+                                                     pac_expectation_var_model_name,
                                                      pac_expectation_discount_id,
                                                      pac_expectation_growth_id);
 
@@ -2708,6 +2712,15 @@ ParsingDriver::add_pac_expectation_model_name(string *arg)
   delete arg;
 }
 
+void
+ParsingDriver::add_pac_expectation_var_model_name(string *arg)
+{
+  if (!pac_expectation_var_model_name.empty())
+    error("pac_expectation: you can only pass the var_model_name option once");
+  pac_expectation_var_model_name = *arg;
+  delete arg;
+}
+
 void
 ParsingDriver::add_pac_expectation_discount(string *arg)
 {
diff --git a/ParsingDriver.hh b/ParsingDriver.hh
index c83793a6ebfeed58d22272100a8faa665e5092f8..3b4d28ab9ca963eb244882fe9a4c43839f320e17 100644
--- a/ParsingDriver.hh
+++ b/ParsingDriver.hh
@@ -253,7 +253,7 @@ private:
   void clear_VAR_storage();
 
   //! Used by pac_expectation
-  string pac_expectation_model_name, pac_expectation_discount, pac_expectation_growth;
+  string pac_expectation_model_name, pac_expectation_var_model_name, pac_expectation_discount, pac_expectation_growth;
 
 public:
   ParsingDriver(WarningConsolidation &warnings_arg, bool nostrict_arg) : warnings(warnings_arg), nostrict(nostrict_arg), model_error_encountered(false)
@@ -694,6 +694,7 @@ public:
   expr_t add_pac_expectation();
   //! Adds arguments for pac_expectation
   void add_pac_expectation_model_name(string *arg);
+  void add_pac_expectation_var_model_name(string *arg);
   void add_pac_expectation_discount(string *arg);
   void add_pac_expectation_growth(string *arg);
   //! Writes token "diff(arg1)" to model tree