Commit ebb00953 authored by sebastien's avatar sebastien
Browse files

trunk preprocessor: allow zero equation if standalone BVAR estimation


git-svn-id: https://www.dynare.org/svn/dynare/dynare_v4@2170 ac1d8469-bf42-47a9-8791-bf33cf982152
parent ccf0c4b9
......@@ -848,7 +848,7 @@ PlannerObjectiveStatement::checkPass(ModFileStructure &mod_file_struct)
{
if (model_tree->equation_number() != 1)
{
cerr << "Error: planer_objective: should have only one equation!" << endl;
cerr << "ERROR: planer_objective: should have only one equation!" << endl;
exit(-1);
}
}
......@@ -872,6 +872,12 @@ BVARDensityStatement::BVARDensityStatement(int maxnlags_arg, const OptionsList &
{
}
void
BVARDensityStatement::checkPass(ModFileStructure &mod_file_struct)
{
mod_file_struct.bvar_density_present = true;
}
void
BVARDensityStatement::writeOutput(ostream &output, const string &basename) const
{
......@@ -885,6 +891,12 @@ BVARForecastStatement::BVARForecastStatement(int nlags_arg, const OptionsList &o
{
}
void
BVARForecastStatement::checkPass(ModFileStructure &mod_file_struct)
{
mod_file_struct.bvar_forecast_present = true;
}
void
BVARForecastStatement::writeOutput(ostream &output, const string &basename) const
{
......
......@@ -75,8 +75,15 @@ ModFile::checkPass()
exit(-1);
}
// Enforce the same number of equations and endogenous if ramsey_policy not present
if (!mod_file_struct.ramsey_policy_present && (model_tree.equation_number() != symbol_table.endo_nbr))
/*
Enforce the same number of equations and endogenous, except in two cases:
- ramsey_policy is used
- a BVAR command is used and there is no equation (standalone BVAR estimation)
*/
if (!mod_file_struct.ramsey_policy_present
&& !((mod_file_struct.bvar_density_present || mod_file_struct.bvar_forecast_present)
&& model_tree.equation_number() == 0)
&& (model_tree.equation_number() != symbol_table.endo_nbr))
{
cerr << "ERROR: There are " << model_tree.equation_number() << " equations but " << symbol_table.endo_nbr << " endogenous variables!" << endl;
exit(-1);
......
......@@ -27,7 +27,9 @@ ModFileStructure::ModFileStructure() :
forecast_present(false),
osr_present(false),
ramsey_policy_present(false),
order_option(0)
order_option(0),
bvar_density_present(false),
bvar_forecast_present(false)
{
}
......
......@@ -445,6 +445,7 @@ private:
const OptionsList options_list;
public:
BVARDensityStatement(int maxnlags_arg, const OptionsList &options_list_arg);
virtual void checkPass(ModFileStructure &mod_file_struct);
virtual void writeOutput(ostream &output, const string &basename) const;
};
......@@ -455,8 +456,8 @@ private:
const OptionsList options_list;
public:
BVARForecastStatement(int nlags_arg, const OptionsList &options_list_arg);
virtual void checkPass(ModFileStructure &mod_file_struct);
virtual void writeOutput(ostream &output, const string &basename) const;
};
#endif
......@@ -50,6 +50,10 @@ public:
//! Derivation order
/*! First initialized to zero. If user sets order option somewhere in the MOD file, it will be equal to the maximum of order options. Otherwise will default to 2 */
int order_option;
//! Whether a bvar_density statement is present
bool bvar_density_present;
//! Whether a bvar_forecast statement is present
bool bvar_forecast_present;
};
class Statement
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment