Skip to content
Snippets Groups Projects
Verified Commit a4ef5a01 authored by Houtan Bastani's avatar Houtan Bastani
Browse files

Epilogue: handle case where `dseries.firstobservedperiod` ends in an error

issue #36
parent 4f20b114
No related branches found
No related tags found
No related merge requests found
...@@ -447,7 +447,12 @@ Epilogue::writeDynamicEpilogueFile(const string & basename) const ...@@ -447,7 +447,12 @@ Epilogue::writeDynamicEpilogueFile(const string & basename) const
expr->collectVariables(SymbolType::exogenous, used_symbols); expr->collectVariables(SymbolType::exogenous, used_symbols);
expr->collectVariables(SymbolType::epilogue, used_symbols); expr->collectVariables(SymbolType::epilogue, used_symbols);
output << "simul_begin_date = firstobservedperiod(ds{"; output << endl
<< "if ~ds.exist('" << symbol_table.getName(symb_id) << "')" << endl
<< " ds = [ds dseries(NaN(ds.nobs,1), ds.firstdate, '" << symbol_table.getName(symb_id)<< "')];" << endl
<< "end" << endl
<< "try" << endl
<< " simul_begin_date = firstobservedperiod(ds{";
for (auto it1 = used_symbols.begin(); it1 != used_symbols.end(); ++it1) for (auto it1 = used_symbols.begin(); it1 != used_symbols.end(); ++it1)
{ {
if (it1 != used_symbols.begin()) if (it1 != used_symbols.begin())
...@@ -455,14 +460,12 @@ Epilogue::writeDynamicEpilogueFile(const string & basename) const ...@@ -455,14 +460,12 @@ Epilogue::writeDynamicEpilogueFile(const string & basename) const
output << "'" << symbol_table.getName(*it1) << "'"; output << "'" << symbol_table.getName(*it1) << "'";
} }
output << "}) + " << max_lag << ";" << endl output << "}) + " << max_lag << ";" << endl
<< "if ~ds.exist('" << symbol_table.getName(symb_id) << "')" << endl
<< " ds = [ds dseries(NaN(ds.nobs,1), ds.firstdate, '" << symbol_table.getName(symb_id)<< "')];" << endl
<< "end" << endl
<< " from simul_begin_date to simul_end_date do " << " from simul_begin_date to simul_end_date do "
<< "ds." << symbol_table.getName(symb_id) << "(t) = "; << "ds." << symbol_table.getName(symb_id) << "(t) = ";
expr->writeOutput(output, ExprNodeOutputType::epilogueFile, temporary_terms, temporary_terms_idxs, tef_terms); expr->writeOutput(output, ExprNodeOutputType::epilogueFile, temporary_terms, temporary_terms_idxs, tef_terms);
output << ";" << endl << endl; output << ";" << endl
<< "catch" << endl
<< "end" << endl;
} }
output << "end" << endl; output << "end" << endl;
output.close(); output.close();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment