DSGE-VAR: introduce dsge_var and dsge_varlag options to estimation statement
parent
b5a3cb227c
commit
9b5df05804
|
@ -63,8 +63,8 @@ options_.steadystate_partial = [];
|
||||||
options_.ParamSubSet = 'None';
|
options_.ParamSubSet = 'None';
|
||||||
|
|
||||||
% bvar-dsge
|
% bvar-dsge
|
||||||
options_.bvar_dsge = 0;
|
options_.dsge_var = 0;
|
||||||
options_.varlag = 4;
|
options_.dsge_varlag = 4;
|
||||||
|
|
||||||
% Optimization algorithm [6] gmhmaxlik
|
% Optimization algorithm [6] gmhmaxlik
|
||||||
options_.Opt6Iter = 2;
|
options_.Opt6Iter = 2;
|
||||||
|
|
|
@ -208,9 +208,11 @@ RamseyPolicyStatement::writeOutput(ostream &output, const string &basename) cons
|
||||||
}
|
}
|
||||||
|
|
||||||
EstimationStatement::EstimationStatement(const SymbolList &symbol_list_arg,
|
EstimationStatement::EstimationStatement(const SymbolList &symbol_list_arg,
|
||||||
const OptionsList &options_list_arg) :
|
const OptionsList &options_list_arg,
|
||||||
|
const SymbolTable &symbol_table_arg) :
|
||||||
symbol_list(symbol_list_arg),
|
symbol_list(symbol_list_arg),
|
||||||
options_list(options_list_arg)
|
options_list(options_list_arg),
|
||||||
|
symbol_table(symbol_table_arg)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -228,6 +230,38 @@ EstimationStatement::checkPass(ModFileStructure &mod_file_struct)
|
||||||
it = options_list.num_options.find("partial_information");
|
it = options_list.num_options.find("partial_information");
|
||||||
if (it != options_list.num_options.end() && it->second == "1")
|
if (it != options_list.num_options.end() && it->second == "1")
|
||||||
mod_file_struct.partial_information = true;
|
mod_file_struct.partial_information = true;
|
||||||
|
|
||||||
|
// Fill in mod_file_struct.dsge_var_calibrated
|
||||||
|
it = options_list.num_options.find("dsge_var");
|
||||||
|
if (it != options_list.num_options.end())
|
||||||
|
mod_file_struct.dsge_var_calibrated = it->second;
|
||||||
|
|
||||||
|
// Fill in mod_file_struct.dsge_var_estimated
|
||||||
|
OptionsList::string_options_type::const_iterator it_str = options_list.string_options.find("dsge_var");
|
||||||
|
if (it_str != options_list.string_options.end())
|
||||||
|
mod_file_struct.dsge_var_estimated = true;
|
||||||
|
|
||||||
|
// Fill in mod_file_struct.bayesian_irf_present
|
||||||
|
it = options_list.num_options.find("bayesian_irf");
|
||||||
|
if (it != options_list.num_options.end() && it->second == "1")
|
||||||
|
mod_file_struct.bayesian_irf_present = true;
|
||||||
|
|
||||||
|
it = options_list.num_options.find("dsge_varlag");
|
||||||
|
if (it != options_list.num_options.end())
|
||||||
|
if (mod_file_struct.dsge_var_calibrated.empty() &&
|
||||||
|
!mod_file_struct.dsge_var_estimated)
|
||||||
|
{
|
||||||
|
cerr << "ERROR: The estimation statement requires a dsge_var option to be passed "
|
||||||
|
<< "if the dsge_varlag option is passed." << endl;
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!mod_file_struct.dsge_var_calibrated.empty() &&
|
||||||
|
mod_file_struct.dsge_var_estimated)
|
||||||
|
{
|
||||||
|
cerr << "ERROR: An estimation statement cannot take more than one dsge_var option." << endl;
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -328,6 +362,15 @@ EstimatedParamsStatement::EstimatedParamsStatement(const vector<EstimationParams
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
EstimatedParamsStatement::checkPass(ModFileStructure &mod_file_struct)
|
||||||
|
{
|
||||||
|
for (vector<EstimationParams>::const_iterator it = estim_params_list.begin();
|
||||||
|
it != estim_params_list.end(); it++)
|
||||||
|
if (it->name == "dsge_prior_weight")
|
||||||
|
mod_file_struct.dsge_prior_weight_in_estimated_params = true;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
EstimatedParamsStatement::writeOutput(ostream &output, const string &basename) const
|
EstimatedParamsStatement::writeOutput(ostream &output, const string &basename) const
|
||||||
{
|
{
|
||||||
|
|
|
@ -147,9 +147,11 @@ class EstimationStatement : public Statement
|
||||||
private:
|
private:
|
||||||
const SymbolList symbol_list;
|
const SymbolList symbol_list;
|
||||||
const OptionsList options_list;
|
const OptionsList options_list;
|
||||||
|
const SymbolTable &symbol_table;
|
||||||
public:
|
public:
|
||||||
EstimationStatement(const SymbolList &symbol_list_arg,
|
EstimationStatement(const SymbolList &symbol_list_arg,
|
||||||
const OptionsList &options_list_arg);
|
const OptionsList &options_list_arg,
|
||||||
|
const SymbolTable &symbol_table);
|
||||||
virtual void checkPass(ModFileStructure &mod_file_struct);
|
virtual void checkPass(ModFileStructure &mod_file_struct);
|
||||||
virtual void writeOutput(ostream &output, const string &basename) const;
|
virtual void writeOutput(ostream &output, const string &basename) const;
|
||||||
};
|
};
|
||||||
|
@ -267,6 +269,7 @@ private:
|
||||||
public:
|
public:
|
||||||
EstimatedParamsStatement(const vector<EstimationParams> &estim_params_list_arg,
|
EstimatedParamsStatement(const vector<EstimationParams> &estim_params_list_arg,
|
||||||
const SymbolTable &symbol_table_arg);
|
const SymbolTable &symbol_table_arg);
|
||||||
|
virtual void checkPass(ModFileStructure &mod_file_struct);
|
||||||
virtual void writeOutput(ostream &output, const string &basename) const;
|
virtual void writeOutput(ostream &output, const string &basename) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -117,7 +117,7 @@ class ParsingDriver;
|
||||||
%token PARAMETERS PARAMETER_SET PARTIAL_INFORMATION PERIODS PLANNER_OBJECTIVE PLOT_CONDITIONAL_FORECAST PLOT_PRIORS PREFILTER PRESAMPLE
|
%token PARAMETERS PARAMETER_SET PARTIAL_INFORMATION PERIODS PLANNER_OBJECTIVE PLOT_CONDITIONAL_FORECAST PLOT_PRIORS PREFILTER PRESAMPLE
|
||||||
%token PRINT PRIOR_MC PRIOR_TRUNC PRIOR_MODE PRIOR_MEAN POSTERIOR_MODE POSTERIOR_MEAN POSTERIOR_MEDIAN PRUNING
|
%token PRINT PRIOR_MC PRIOR_TRUNC PRIOR_MODE PRIOR_MEAN POSTERIOR_MODE POSTERIOR_MEAN POSTERIOR_MEDIAN PRUNING
|
||||||
%token <string_val> QUOTED_STRING
|
%token <string_val> QUOTED_STRING
|
||||||
%token QZ_CRITERIUM FULL
|
%token QZ_CRITERIUM FULL DSGE_VAR DSGE_VARLAG DSGE_PRIOR_WEIGHT
|
||||||
%token RELATIVE_IRF REPLIC RPLOT SAVE_PARAMS_AND_STEADY_STATE
|
%token RELATIVE_IRF REPLIC RPLOT SAVE_PARAMS_AND_STEADY_STATE
|
||||||
%token SHOCKS SHOCK_DECOMPOSITION SIGMA_E SIMUL SIMUL_ALGO SIMUL_SEED SMOOTHER STACK_SOLVE_ALGO STEADY_STATE_MODEL SOLVE_ALGO
|
%token SHOCKS SHOCK_DECOMPOSITION SIGMA_E SIMUL SIMUL_ALGO SIMUL_SEED SMOOTHER STACK_SOLVE_ALGO STEADY_STATE_MODEL SOLVE_ALGO
|
||||||
%token STDERR STEADY STOCH_SIMUL
|
%token STDERR STEADY STOCH_SIMUL
|
||||||
|
@ -927,6 +927,12 @@ estimated_elem1 : STDERR symbol
|
||||||
delete $2;
|
delete $2;
|
||||||
delete $4;
|
delete $4;
|
||||||
}
|
}
|
||||||
|
| DSGE_PRIOR_WEIGHT
|
||||||
|
{
|
||||||
|
driver.declare_dsge_prior_weight();
|
||||||
|
driver.estim_params.type = 2;
|
||||||
|
driver.estim_params.name = "dsge_prior_weight";
|
||||||
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
estimated_elem2 : prior COMMA estimated_elem3
|
estimated_elem2 : prior COMMA estimated_elem3
|
||||||
|
@ -1126,6 +1132,8 @@ estimation_options : o_datafile
|
||||||
| o_loglinear
|
| o_loglinear
|
||||||
| o_nodiagnostic
|
| o_nodiagnostic
|
||||||
| o_bayesian_irf
|
| o_bayesian_irf
|
||||||
|
| o_dsge_var
|
||||||
|
| o_dsge_varlag
|
||||||
| o_irf
|
| o_irf
|
||||||
| o_tex
|
| o_tex
|
||||||
| o_forecast
|
| o_forecast
|
||||||
|
@ -1734,6 +1742,14 @@ o_load_mh_file : LOAD_MH_FILE { driver.option_num("load_mh_file", "1"); };
|
||||||
o_loglinear : LOGLINEAR { driver.option_num("loglinear", "1"); };
|
o_loglinear : LOGLINEAR { driver.option_num("loglinear", "1"); };
|
||||||
o_nodiagnostic : NODIAGNOSTIC { driver.option_num("nodiagnostic", "1"); };
|
o_nodiagnostic : NODIAGNOSTIC { driver.option_num("nodiagnostic", "1"); };
|
||||||
o_bayesian_irf : BAYESIAN_IRF { driver.option_num("bayesian_irf", "1"); };
|
o_bayesian_irf : BAYESIAN_IRF { driver.option_num("bayesian_irf", "1"); };
|
||||||
|
o_dsge_var : DSGE_VAR EQUAL number
|
||||||
|
{ driver.option_num("dsge_var", $3); }
|
||||||
|
| DSGE_VAR EQUAL INF_CONSTANT
|
||||||
|
{ driver.option_num("dsge_var", "Inf"); }
|
||||||
|
| DSGE_VAR
|
||||||
|
{ driver.option_str("dsge_var", "NaN"); }
|
||||||
|
;
|
||||||
|
o_dsge_varlag : DSGE_VARLAG EQUAL INT_NUMBER { driver.option_num("dsge_varlag", $3); };
|
||||||
o_tex : TEX { driver.option_num("TeX", "1"); };
|
o_tex : TEX { driver.option_num("TeX", "1"); };
|
||||||
o_forecast : FORECAST EQUAL INT_NUMBER { driver.option_num("forecast", $3); };
|
o_forecast : FORECAST EQUAL INT_NUMBER { driver.option_num("forecast", $3); };
|
||||||
o_smoother : SMOOTHER { driver.option_num("smoother", "1"); };
|
o_smoother : SMOOTHER { driver.option_num("smoother", "1"); };
|
||||||
|
|
|
@ -208,6 +208,8 @@ string eofbuff;
|
||||||
<DYNARE_STATEMENT>forecast {return token::FORECAST;}
|
<DYNARE_STATEMENT>forecast {return token::FORECAST;}
|
||||||
<DYNARE_STATEMENT>smoother {return token::SMOOTHER;}
|
<DYNARE_STATEMENT>smoother {return token::SMOOTHER;}
|
||||||
<DYNARE_STATEMENT>bayesian_irf {return token::BAYESIAN_IRF;}
|
<DYNARE_STATEMENT>bayesian_irf {return token::BAYESIAN_IRF;}
|
||||||
|
<DYNARE_STATEMENT>dsge_var {return token::DSGE_VAR;}
|
||||||
|
<DYNARE_STATEMENT>dsge_varlag {return token::DSGE_VARLAG;}
|
||||||
<DYNARE_STATEMENT>moments_varendo {return token::MOMENTS_VARENDO;}
|
<DYNARE_STATEMENT>moments_varendo {return token::MOMENTS_VARENDO;}
|
||||||
<DYNARE_STATEMENT>filtered_vars {return token::FILTERED_VARS;}
|
<DYNARE_STATEMENT>filtered_vars {return token::FILTERED_VARS;}
|
||||||
<DYNARE_STATEMENT>filter_step_ahead {return token::FILTER_STEP_AHEAD;}
|
<DYNARE_STATEMENT>filter_step_ahead {return token::FILTER_STEP_AHEAD;}
|
||||||
|
@ -377,6 +379,7 @@ string eofbuff;
|
||||||
<DYNARE_BLOCK>inv_gamma1_pdf {return token::INV_GAMMA1_PDF;}
|
<DYNARE_BLOCK>inv_gamma1_pdf {return token::INV_GAMMA1_PDF;}
|
||||||
<DYNARE_BLOCK>inv_gamma2_pdf {return token::INV_GAMMA2_PDF;}
|
<DYNARE_BLOCK>inv_gamma2_pdf {return token::INV_GAMMA2_PDF;}
|
||||||
<DYNARE_BLOCK>uniform_pdf {return token::UNIFORM_PDF;}
|
<DYNARE_BLOCK>uniform_pdf {return token::UNIFORM_PDF;}
|
||||||
|
<DYNARE_BLOCK>dsge_prior_weight {return token::DSGE_PRIOR_WEIGHT;}
|
||||||
|
|
||||||
<DYNARE_BLOCK>; {return Dynare::parser::token_type (yytext[0]);}
|
<DYNARE_BLOCK>; {return Dynare::parser::token_type (yytext[0]);}
|
||||||
<DYNARE_BLOCK># {return Dynare::parser::token_type (yytext[0]);}
|
<DYNARE_BLOCK># {return Dynare::parser::token_type (yytext[0]);}
|
||||||
|
|
|
@ -144,6 +144,22 @@ ModFile::checkPass()
|
||||||
cerr << "ERROR: In 'model' block, use of external functions is not compatible with 'use_dll' or 'bytecode'" << endl;
|
cerr << "ERROR: In 'model' block, use of external functions is not compatible with 'use_dll' or 'bytecode'" << endl;
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (mod_file_struct.dsge_var_estimated)
|
||||||
|
if (!mod_file_struct.dsge_prior_weight_in_estimated_params)
|
||||||
|
{
|
||||||
|
cerr << "ERROR: When estimating a DSGE-VAR model and estimating the weight of the prior, dsge_prior_weight must "
|
||||||
|
<< "be referenced in the estimated_params block." << endl;
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mod_file_struct.dsge_prior_weight_in_estimated_params)
|
||||||
|
if (!mod_file_struct.dsge_var_estimated)
|
||||||
|
{
|
||||||
|
cerr << "ERROR: If dsge_prior_weight is in the estimated_params_block, the prior weight cannot be calibrated "
|
||||||
|
<< "via the dsge_var option in the estimation statement." << endl;
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -167,6 +183,20 @@ ModFile::transformPass()
|
||||||
dynamic_model.substituteExoLag();
|
dynamic_model.substituteExoLag();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!mod_file_struct.dsge_var_calibrated.empty())
|
||||||
|
try
|
||||||
|
{
|
||||||
|
addStatement(new InitParamStatement(symbol_table.addSymbol("dsge_prior_weight", eParameter),
|
||||||
|
expressions_tree.AddNumConstant(mod_file_struct.dsge_var_calibrated),
|
||||||
|
symbol_table));
|
||||||
|
}
|
||||||
|
catch (SymbolTable::AlreadyDeclaredException &e)
|
||||||
|
{
|
||||||
|
cerr << "ERROR: dsge_prior_weight should not be declared as a model variable / parameter "
|
||||||
|
<< "when the dsge_var option is passed to the estimation statement." << endl;
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
|
||||||
// Freeze the symbol table
|
// Freeze the symbol table
|
||||||
symbol_table.freeze();
|
symbol_table.freeze();
|
||||||
|
|
||||||
|
@ -184,6 +214,24 @@ ModFile::transformPass()
|
||||||
}
|
}
|
||||||
|
|
||||||
cout << "Found " << dynamic_model.equation_number() << " equation(s)." << endl;
|
cout << "Found " << dynamic_model.equation_number() << " equation(s)." << endl;
|
||||||
|
|
||||||
|
if (!mod_file_struct.dsge_var_calibrated.empty() || mod_file_struct.dsge_var_estimated)
|
||||||
|
if (mod_file_struct.bayesian_irf_present)
|
||||||
|
{
|
||||||
|
if (symbol_table.exo_nbr() != symbol_table.observedVariablesNbr())
|
||||||
|
{
|
||||||
|
cerr << "ERROR: If bayesian_irf and dsge_var are passed to the estimation statement, "
|
||||||
|
<< "the number of shocks must equal the number of observed variables." << endl;
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
if (symbol_table.exo_nbr() < symbol_table.observedVariablesNbr())
|
||||||
|
{
|
||||||
|
cerr << "ERROR: If dsge_var is passed to the estimation statement, the number of shocks "
|
||||||
|
<< "must be greater than or equal to the number of observed variables." << endl;
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
@ -164,6 +164,16 @@ ParsingDriver::declare_parameter(string *name, string *tex_name)
|
||||||
delete tex_name;
|
delete tex_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
ParsingDriver::declare_dsge_prior_weight()
|
||||||
|
{
|
||||||
|
if (mod_file->symbol_table.exists("dsge_prior_weight"))
|
||||||
|
error("If dsge_prior_weight appears in the estimated_params block, it cannot have been previosly declared.");
|
||||||
|
|
||||||
|
string *dsge_prior_weight = new string("dsge_prior_weight");
|
||||||
|
declare_parameter(dsge_prior_weight);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ParsingDriver::add_predetermined_variable(string *name)
|
ParsingDriver::add_predetermined_variable(string *name)
|
||||||
{
|
{
|
||||||
|
@ -922,7 +932,7 @@ ParsingDriver::set_unit_root_vars()
|
||||||
void
|
void
|
||||||
ParsingDriver::run_estimation()
|
ParsingDriver::run_estimation()
|
||||||
{
|
{
|
||||||
mod_file->addStatement(new EstimationStatement(symbol_list, options_list));
|
mod_file->addStatement(new EstimationStatement(symbol_list, options_list, mod_file->symbol_table));
|
||||||
symbol_list.clear();
|
symbol_list.clear();
|
||||||
options_list.clear();
|
options_list.clear();
|
||||||
}
|
}
|
||||||
|
|
|
@ -212,6 +212,8 @@ public:
|
||||||
void declare_exogenous_det(string *name, string *tex_name = NULL);
|
void declare_exogenous_det(string *name, string *tex_name = NULL);
|
||||||
//! Declares a parameter
|
//! Declares a parameter
|
||||||
void declare_parameter(string *name, string *tex_name = NULL);
|
void declare_parameter(string *name, string *tex_name = NULL);
|
||||||
|
//! Declares dsge_prior_weight
|
||||||
|
void declare_dsge_prior_weight();
|
||||||
//! Adds a predetermined_variable
|
//! Adds a predetermined_variable
|
||||||
void add_predetermined_variable(string *name);
|
void add_predetermined_variable(string *name);
|
||||||
//! Declares and initializes a local parameter
|
//! Declares and initializes a local parameter
|
||||||
|
|
|
@ -34,7 +34,11 @@ ModFileStructure::ModFileStructure() :
|
||||||
partial_information(false),
|
partial_information(false),
|
||||||
shocks_present(false),
|
shocks_present(false),
|
||||||
k_order_solver(false),
|
k_order_solver(false),
|
||||||
calibrated_measurement_errors(false)
|
calibrated_measurement_errors(false),
|
||||||
|
dsge_prior_weight_in_estimated_params(false),
|
||||||
|
dsge_var_calibrated(""),
|
||||||
|
dsge_var_estimated(false),
|
||||||
|
bayesian_irf_present(false)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -65,6 +65,14 @@ public:
|
||||||
bool k_order_solver;
|
bool k_order_solver;
|
||||||
//! Whether there is a calibrated measurement error
|
//! Whether there is a calibrated measurement error
|
||||||
bool calibrated_measurement_errors;
|
bool calibrated_measurement_errors;
|
||||||
|
//! Whether dsge_prior_weight is in the estimated_params block
|
||||||
|
bool dsge_prior_weight_in_estimated_params;
|
||||||
|
//! Whether there is a dsge_var, with calibrated prior weight
|
||||||
|
string dsge_var_calibrated;
|
||||||
|
//! Whether there is a dsge_var, with prior weight that must be estimated
|
||||||
|
bool dsge_var_estimated;
|
||||||
|
//! Whether there is a bayesian_irf option passed to the estimation statement
|
||||||
|
bool bayesian_irf_present;
|
||||||
};
|
};
|
||||||
|
|
||||||
class Statement
|
class Statement
|
||||||
|
|
Loading…
Reference in New Issue