New field M_.endo_trends

For each endogenous variable, gives the deflator and the growth factor (as well
as the “log” versions).

Ref. dynare#1648
issue#70
Sébastien Villemot 2019-12-13 17:27:50 +01:00
parent 2af26ee2c2
commit 141cff0761
No known key found for this signature in database
GPG Key ID: 2CECE9350ECEBE4A
1 changed files with 27 additions and 0 deletions

View File

@ -3697,6 +3697,33 @@ DynamicModel::writeOutput(ostream &output, const string &basename, bool block_de
output << modstruct << "params = " << (julia ? "fill(NaN, " : "NaN(")
<< symbol_table.param_nbr() << (julia ? ")" : ", 1);") << endl;
// FIXME: implement this for Julia
if (!julia)
{
string empty_cell = "cell(" + to_string(symbol_table.endo_nbr()) + ", 1)";
output << modstruct << "endo_trends = struct('deflator', " << empty_cell
<< ", 'log_deflator', " << empty_cell << ", 'growth_factor', " << empty_cell
<< ", 'log_growth_factor', " << empty_cell << ");" << endl;
for (int i = 0; i < symbol_table.endo_nbr(); i++)
{
int symb_id = symbol_table.getID(SymbolType::endogenous, i);
if (auto it = nonstationary_symbols_map.find(symb_id); it != nonstationary_symbols_map.end())
{
auto [is_log, deflator] = it->second;
output << modstruct << "endo_trends(" << i << ")."
<< (is_log ? "log_deflator" : "deflator") << " = '";
deflator->writeJsonOutput(output, {}, {});
output << "';" << endl;
auto growth_factor = const_cast<DynamicModel *>(this)->AddDivide(deflator, deflator->decreaseLeadsLags(1))->removeTrendLeadLag(trend_symbols_map)->replaceTrendVar();
output << modstruct << "endo_trends(" << i << ")."
<< (is_log ? "log_growth_factor" : "growth_factor") << " = '";
growth_factor->writeJsonOutput(output, {}, {});
output << "';" << endl;
}
}
}
if (compute_xrefs)
writeXrefs(output);