From bd9e8acdabd80901145ad5a83a163ced75f2442f Mon Sep 17 00:00:00 2001 From: Houtan Bastani Date: Mon, 28 Oct 2013 15:29:41 +0100 Subject: [PATCH] preprocessor: move M_.Correlation_matrix and M_.Correlation_matrix_ME to preprocessor #392 --- ModFile.cc | 9 +++++++-- Shocks.cc | 13 ++++++++++++- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/ModFile.cc b/ModFile.cc index 631dc4fa..1abb76ce 100644 --- a/ModFile.cc +++ b/ModFile.cc @@ -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; diff --git a/Shocks.cc b/Shocks.cc index ab5b36df..1a943d2c 100644 --- a/Shocks.cc +++ b/Shocks.cc @@ -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