fix bugs in creation of AR/EC matrices

issue#70
Houtan Bastani 2018-09-12 11:56:53 +02:00
parent aa120abd02
commit 0376f7f173
1 changed files with 5 additions and 8 deletions

View File

@ -3716,7 +3716,8 @@ DynamicModel::fillVarModelTableFromOrigModel(StaticModel &static_model) const
void void
DynamicModel::fillAutoregressiveMatrix(map<string, map<tuple<int, int, int>, expr_t>> &ARr, bool is_trend_component_model) const DynamicModel::fillAutoregressiveMatrix(map<string, map<tuple<int, int, int>, expr_t>> &ARr, bool is_trend_component_model) const
{ {
auto eqnums = is_trend_component_model ? trend_component_model_table.getEqNums() : var_model_table.getEqNums(); auto eqnums = is_trend_component_model ?
trend_component_model_table.getNonTrendEqNums() : var_model_table.getEqNums();
for (const auto & it : eqnums) for (const auto & it : eqnums)
{ {
int i = 0; int i = 0;
@ -3855,17 +3856,13 @@ DynamicModel::fillTrendComponentModelTable() const
void void
DynamicModel::fillErrorComponentMatrix(map<string, map<tuple<int, int, int>, expr_t>> &ECr) const DynamicModel::fillErrorComponentMatrix(map<string, map<tuple<int, int, int>, expr_t>> &ECr) const
{ {
for (const auto & it : trend_component_model_table.getEqNums()) for (const auto & it : trend_component_model_table.getNonTrendEqNums())
{ {
vector<int> nontrend_lhs;
vector<int> lhsv = trend_component_model_table.getLhs(it.first);
for (int trend_it : trend_component_model_table.getTrendEqNums(it.first))
nontrend_lhs.push_back(lhsv.at(distance(it.second.begin(), find(it.second.begin(), it.second.end(), trend_it))));
int i = 0; int i = 0;
map<tuple<int, int, int>, expr_t> EC; map<tuple<int, int, int>, expr_t> EC;
vector<int> trend_lhs = trend_component_model_table.getTrendLhs(it.first);
for (auto eqn : it.second) for (auto eqn : it.second)
equations[eqn]->get_arg2()->fillErrorCorrectionRow(i++, nontrend_lhs, EC); equations[eqn]->get_arg2()->fillErrorCorrectionRow(i++, trend_lhs, EC);
ECr[it.first] = EC; ECr[it.first] = EC;
} }
} }