Do not allow the estimation of a parameter that appears in “planner_discount”
Ref. dynare#1173issue#70
parent
12296b620f
commit
c4a9f93d40
|
@ -34,6 +34,7 @@ using namespace std;
|
|||
#pragma GCC diagnostic pop
|
||||
|
||||
#include <utility>
|
||||
#include <algorithm>
|
||||
|
||||
SteadyStatement::SteadyStatement(OptionsList options_list_arg) :
|
||||
options_list{move(options_list_arg)}
|
||||
|
@ -1134,8 +1135,10 @@ DiscretionaryPolicyStatement::writeJsonOutput(ostream &output) const
|
|||
output << "}";
|
||||
}
|
||||
|
||||
EstimationStatement::EstimationStatement(SymbolList symbol_list_arg,
|
||||
EstimationStatement::EstimationStatement(const SymbolTable &symbol_table_arg,
|
||||
SymbolList symbol_list_arg,
|
||||
OptionsList options_list_arg) :
|
||||
symbol_table{symbol_table_arg},
|
||||
symbol_list{move(symbol_list_arg)},
|
||||
options_list{move(options_list_arg)}
|
||||
{
|
||||
|
@ -1212,6 +1215,22 @@ EstimationStatement::checkPass(ModFileStructure &mod_file_struct, WarningConsoli
|
|||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
/* Check that we are not trying to estimate a parameter appearing in the
|
||||
planner discount factor (see dynare#1173) */
|
||||
vector<int> estimated_params_in_planner_discount;
|
||||
set_intersection(mod_file_struct.estimated_parameters.begin(),
|
||||
mod_file_struct.estimated_parameters.end(),
|
||||
mod_file_struct.parameters_in_planner_discount.begin(),
|
||||
mod_file_struct.parameters_in_planner_discount.end(),
|
||||
back_inserter(estimated_params_in_planner_discount));
|
||||
if (!estimated_params_in_planner_discount.empty())
|
||||
{
|
||||
cerr << "ERROR: It is not possible to estimate a parameter ("
|
||||
<< symbol_table.getName(estimated_params_in_planner_discount[0])
|
||||
<< ") that appears in the discount factor of the planner (i.e. in the 'planner_discount' option)." << endl;
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
symbol_list.checkPass(warnings, { SymbolType::endogenous });
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright © 2003-2019 Dynare Team
|
||||
* Copyright © 2003-2020 Dynare Team
|
||||
*
|
||||
* This file is part of Dynare.
|
||||
*
|
||||
|
@ -314,10 +314,12 @@ public:
|
|||
class EstimationStatement : public Statement
|
||||
{
|
||||
private:
|
||||
const SymbolTable &symbol_table;
|
||||
const SymbolList symbol_list;
|
||||
const OptionsList options_list;
|
||||
public:
|
||||
EstimationStatement(SymbolList symbol_list_arg,
|
||||
EstimationStatement(const SymbolTable &symbol_table_arg,
|
||||
SymbolList symbol_list_arg,
|
||||
OptionsList options_list_arg);
|
||||
void checkPass(ModFileStructure &mod_file_struct, WarningConsolidation &warnings) override;
|
||||
void writeOutput(ostream &output, const string &basename, bool minimal_workspace) const override;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright © 2003-2019 Dynare Team
|
||||
* Copyright © 2003-2020 Dynare Team
|
||||
*
|
||||
* This file is part of Dynare.
|
||||
*
|
||||
|
@ -39,6 +39,10 @@ InitParamStatement::checkPass(ModFileStructure &mod_file_struct, WarningConsolid
|
|||
{
|
||||
if (symbol_table.getName(symb_id) == "dsge_prior_weight")
|
||||
mod_file_struct.dsge_prior_weight_initialized = true;
|
||||
|
||||
// Needed for the workaround discussed in dynare#1173
|
||||
if (symbol_table.getName(symb_id) == "optimal_policy_discount_factor")
|
||||
param_value->collectVariables(SymbolType::parameter, mod_file_struct.parameters_in_planner_discount);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright © 2003-2019 Dynare Team
|
||||
* Copyright © 2003-2020 Dynare Team
|
||||
*
|
||||
* This file is part of Dynare.
|
||||
*
|
||||
|
@ -1931,7 +1931,7 @@ ParsingDriver::set_corr_options(const string &name1, const string &name2, const
|
|||
void
|
||||
ParsingDriver::run_estimation()
|
||||
{
|
||||
mod_file->addStatement(make_unique<EstimationStatement>(symbol_list, options_list));
|
||||
mod_file->addStatement(make_unique<EstimationStatement>(mod_file->symbol_table, symbol_list, options_list));
|
||||
symbol_list.clear();
|
||||
options_list.clear();
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright © 2006-2019 Dynare Team
|
||||
* Copyright © 2006-2020 Dynare Team
|
||||
*
|
||||
* This file is part of Dynare.
|
||||
*
|
||||
|
@ -134,6 +134,9 @@ public:
|
|||
/* Whether any of shock_decomposition, realtime_shock_decomposition and
|
||||
initial_condition_decomposition has the “with_epilogue” option */
|
||||
bool with_epilogue_option{false};
|
||||
/* Lists symbol IDs of parameters that appear in a “planner_discount” option.
|
||||
See dynare#1173 for more details. */
|
||||
set<int> parameters_in_planner_discount;
|
||||
};
|
||||
|
||||
class Statement
|
||||
|
|
Loading…
Reference in New Issue