Refuse that estimated parameters appear in the expressions defining the variance/covariance matrix of shocks

Closes #469
issue#70
Sébastien Villemot 2013-11-29 14:50:58 +01:00
parent 645b830dc9
commit 173dc32e60
4 changed files with 53 additions and 0 deletions

View File

@ -517,6 +517,12 @@ EstimatedParamsStatement::checkPass(ModFileStructure &mod_file_struct, WarningCo
} }
} }
} }
// Fill in mod_file_struct.estimated_parameters (related to #469)
for (vector<EstimationParams>::const_iterator it = estim_params_list.begin();
it != estim_params_list.end(); it++)
if (it->type == 2)
mod_file_struct.estimated_parameters.insert(symbol_table.getID(it->name));
} }
void void

View File

@ -264,6 +264,28 @@ ModFile::checkPass()
|| dynamic_model.isBinaryOpUsed(oEqualEqual) || dynamic_model.isBinaryOpUsed(oEqualEqual)
|| dynamic_model.isBinaryOpUsed(oDifferent))) || dynamic_model.isBinaryOpUsed(oDifferent)))
warnings << "WARNING: you are using a function (max, min, abs, sign) or an operator (<, >, <=, >=, ==, !=) which is unsuitable for a stochastic context; see the reference manual, section about \"Expressions\", for more details." << endl; warnings << "WARNING: you are using a function (max, min, abs, sign) or an operator (<, >, <=, >=, ==, !=) which is unsuitable for a stochastic context; see the reference manual, section about \"Expressions\", for more details." << endl;
// Test if some estimated parameters are used within the values of shocks
// statements (see issue #469)
set<int> parameters_intersect;
set_intersection(mod_file_struct.parameters_within_shocks_values.begin(),
mod_file_struct.parameters_within_shocks_values.end(),
mod_file_struct.estimated_parameters.begin(),
mod_file_struct.estimated_parameters.end(),
inserter(parameters_intersect, parameters_intersect.begin()));
if (parameters_intersect.size() > 0)
{
cerr << "ERROR: some estimated parameters (";
for (set<int>::const_iterator it = parameters_intersect.begin();
it != parameters_intersect.end(); )
{
cerr << symbol_table.getName(*it);
if (++it != parameters_intersect.end())
cerr << ", ";
}
cerr << ") also appear in the expressions defining the variance/covariance matrix of shocks; this is not allowed." << endl;
exit(EXIT_FAILURE);
}
} }
void void

View File

@ -284,6 +284,25 @@ ShocksStatement::checkPass(ModFileStructure &mod_file_struct, WarningConsolidati
|| symbol_table.isObservedVariable(it->first.second)) || symbol_table.isObservedVariable(it->first.second))
mod_file_struct.calibrated_measurement_errors = true; mod_file_struct.calibrated_measurement_errors = true;
} }
// Fill in mod_file_struct.parameters_with_shocks_values (related to #469)
set<pair<int, int> > params_lags;
for (var_and_std_shocks_t::const_iterator it = var_shocks.begin();
it != var_shocks.end(); ++it)
it->second->collectVariables(eParameter, params_lags);
for (var_and_std_shocks_t::const_iterator it = std_shocks.begin();
it != std_shocks.end(); ++it)
it->second->collectVariables(eParameter, params_lags);
for (covar_and_corr_shocks_t::const_iterator it = covar_shocks.begin();
it != covar_shocks.end(); ++it)
it->second->collectVariables(eParameter, params_lags);
for (covar_and_corr_shocks_t::const_iterator it = corr_shocks.begin();
it != corr_shocks.end(); ++it)
it->second->collectVariables(eParameter, params_lags);
for (set<pair<int, int> >::const_iterator it = params_lags.begin();
it != params_lags.end(); ++it)
mod_file_struct.parameters_within_shocks_values.insert(it->first);
} }
MShocksStatement::MShocksStatement(const det_shocks_t &det_shocks_arg, MShocksStatement::MShocksStatement(const det_shocks_t &det_shocks_arg,

View File

@ -23,6 +23,7 @@
#include <ostream> #include <ostream>
#include <string> #include <string>
#include <map> #include <map>
#include <set>
#include "SymbolList.hh" #include "SymbolList.hh"
#include "WarningConsolidation.hh" #include "WarningConsolidation.hh"
@ -97,6 +98,11 @@ public:
int last_markov_switching_chain; int last_markov_switching_chain;
//! Whether a calib_smoother statement is present //! Whether a calib_smoother statement is present
bool calib_smoother_present; bool calib_smoother_present;
//! Set of parameters used within shocks blocks, inside the expressions
//! defining the values of covariances (stored as symbol ids)
set<int> parameters_within_shocks_values;
//! Set of estimated parameters (stored as symbol ids)
set<int> estimated_parameters;
}; };
class Statement class Statement