Allow trend_component_model in var_expectations.

issue#70
Stéphane Adjemia (Scylla) 2018-08-22 16:50:01 +02:00
parent 1874fa5cce
commit a406c18598
4 changed files with 20 additions and 10 deletions

View File

@ -4863,7 +4863,7 @@ void
VarExpectationModelStatement::writeOutput(ostream &output, const string &basename, bool minimal_workspace) const
{
string mstruct = "M_.var_expectation." + model_name;
output << mstruct << ".var_model_name = '" << var_model_name << "';" << endl
output << mstruct << ".auxiliary_model_name = '" << var_model_name << "';" << endl
<< mstruct << ".horizon = " << horizon << ';' << endl
<< mstruct << ".variable = '" << variable << "';" << endl
<< mstruct << ".variable_id = " << symbol_table.getTypeSpecificID(variable)+1 << ";" << endl;

View File

@ -410,8 +410,8 @@ var_expectation_model_options_list : var_expectation_model_option
var_expectation_model_option : VARIABLE EQUAL symbol
{ driver.option_str("variable", $3); }
| VAR_MODEL_NAME EQUAL symbol
{ driver.option_str("var_model_name", $3); }
| AUXILIARY_MODEL_NAME EQUAL symbol
{ driver.option_str("auxiliary_model_name", $3); }
| HORIZON EQUAL INT_NUMBER
{ driver.option_num("horizon", $3); }
| HORIZON EQUAL integer_range_w_inf

View File

@ -514,18 +514,28 @@ ModFile::transformPass(bool nostrict, bool stochastic, bool compute_xrefs, const
if (!vems)
continue;
int max_lag;
vector<int> lhs;
auto &model_name = vems->model_name;
if (!var_model_table.isExistingVarModelName(vems->var_model_name))
if (var_model_table.isExistingVarModelName(vems->var_model_name))
{
max_lag = var_model_table.getMaxLag(vems->var_model_name);
lhs = var_model_table.getLhs(vems->var_model_name);
}
else if (trend_component_model_table.isExistingTrendComponentModelName(vems->var_model_name))
{
max_lag = trend_component_model_table.getMaxLag(vems->var_model_name);
lhs = trend_component_model_table.getLhs(vems->var_model_name);
}
else
{
cerr << "ERROR: var_expectation_model " << model_name
<< " refers to nonexistent " << vems->var_model_name << " var_model" << endl;
<< " refers to nonexistent auxiliary model " << vems->var_model_name << endl;
exit(EXIT_FAILURE);
}
/* Create auxiliary parameters and the expression to be substituted to
/* Create auxiliary parameters and the expression to be substituted into
the var_expectations statement */
int max_lag = var_model_table.getMaxLag(vems->var_model_name);
vector<int> lhs = var_model_table.getLhs(vems->var_model_name);
auto subst_expr = dynamic_model.Zero;
for (int lag = 0; lag < max_lag; lag++)
for (auto variable : lhs)

View File

@ -3268,9 +3268,9 @@ ParsingDriver::var_expectation_model()
auto variable = it->second;
check_symbol_is_endogenous(variable);
it = options_list.string_options.find("var_model_name");
it = options_list.string_options.find("auxiliary_model_name");
if (it == options_list.string_options.end())
error("You must pass the var_model_name option to the var_expectation_model statement.");
error("You must pass the auxiliary_model_name option to the var_expectation_model statement.");
auto var_model_name = it->second;
it = options_list.string_options.find("model_name");