Commit 07137e80 authored by Houtan Bastani's avatar Houtan Bastani
Browse files

preprocessor: move M_.Correlation_matrix and M_.Correlation_matrix_ME to preprocessor #392

parent 9230a1ea
......@@ -537,15 +537,20 @@ ModFile::writeOutputFiles(const string &basename, bool clear_all, bool no_log, b
symbol_table.writeOutput(mOutputFile);
// Initialize M_.Sigma_e and M_.H
// Initialize M_.Sigma_e, M_.Correlation_matrix, M_.H, and M_.Correlation_matrix_ME
mOutputFile << "M_.Sigma_e = zeros(" << symbol_table.exo_nbr() << ", "
<< symbol_table.exo_nbr() << ");" << endl
<< "M_.Correlation_matrix = eye(" << symbol_table.exo_nbr() << ", "
<< symbol_table.exo_nbr() << ");" << endl;
if (mod_file_struct.calibrated_measurement_errors)
mOutputFile << "M_.H = zeros(" << symbol_table.observedVariablesNbr() << ", "
<< symbol_table.observedVariablesNbr() << ");" << endl
<< "M_.Correlation_matrix_ME = eye(" << symbol_table.observedVariablesNbr() << ", "
<< symbol_table.observedVariablesNbr() << ");" << endl;
else
mOutputFile << "M_.H = 0;" << endl;
mOutputFile << "M_.H = 0;" << endl
<< "M_.Correlation_matrix_ME = 1;" << endl;
if (linear == 1)
mOutputFile << "options_.linear = 1;" << endl;
......
......@@ -155,17 +155,19 @@ ShocksStatement::writeCovarOrCorrShock(ostream &output, covar_and_corr_shocks_t:
SymbolType type2 = symbol_table.getType(it->first.second);
assert((type1 == eExogenous && type2 == eExogenous)
|| (symbol_table.isObservedVariable(it->first.first) && symbol_table.isObservedVariable(it->first.second)));
string matrix;
string matrix, corr_matrix;
int id1, id2;
if (type1 == eExogenous)
{
matrix = "M_.Sigma_e";
corr_matrix = "M_.Correlation_matrix";
id1 = symbol_table.getTypeSpecificID(it->first.first) + 1;
id2 = symbol_table.getTypeSpecificID(it->first.second) + 1;
}
else
{
matrix = "M_.H";
corr_matrix = "M_.Correlation_matrix_ME";
id1 = symbol_table.getObservedVariableIndex(it->first.first) + 1;
id2 = symbol_table.getObservedVariableIndex(it->first.second) + 1;
}
......@@ -178,6 +180,15 @@ ShocksStatement::writeCovarOrCorrShock(ostream &output, covar_and_corr_shocks_t:
output << ";" << endl
<< matrix << "(" << id2 << ", " << id1 << ") = "
<< matrix << "(" << id1 << ", " << id2 << ");" << endl;
if (corr)
{
output << corr_matrix << "(" << id1 << ", " << id2 << ") = ";
it->second->writeOutput(output);
output << ";" << endl
<< corr_matrix << "(" << id2 << ", " << id1 << ") = "
<< corr_matrix << "(" << id1 << ", " << id2 << ");" << endl;
}
}
void
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment