Refuse non-stationary endogenous variables in deflators.

It is not clear what we should do in that case anyways.
time-shift
Sébastien Villemot 2013-10-29 18:47:59 +08:00
parent f889760f61
commit 9b22dc8096
3 changed files with 16 additions and 0 deletions

View File

@ -1567,3 +1567,10 @@ ModelTree::computeParamsDerivativesTemporaryTerms()
it != hessian_params_derivatives.end(); ++it)
it->second->computeTemporaryTerms(reference_count, params_derivs_temporary_terms, true);
}
bool ModelTree::isNonstationary(int symb_id) const
{
return (nonstationary_symbols_map.find(symb_id)
!= nonstationary_symbols_map.end());
}

View File

@ -307,6 +307,8 @@ public:
void addTrendVariables(vector<int> trend_vars, expr_t growth_factor) throw (TrendException);
//! Adds a nonstationary variables with their (common) deflator
void addNonstationaryVariables(vector<int> nonstationary_vars, bool log_deflator, expr_t deflator) throw (TrendException);
//! Is a given variable non-stationary?
bool isNonstationary(int symb_id) const;
void set_cutoff_to_zero();
//! Helper for writing the Jacobian elements in MATLAB and C
/*! Writes either (i+1,j+1) or [i+j*no_eq] */

View File

@ -357,6 +357,13 @@ ParsingDriver::end_nonstationary_var(bool log_deflator, expr_t deflator)
{
error("Variable " + e.name + " was listed more than once as following a trend.");
}
set<pair<int, int> > r;
deflator->collectVariables(eEndogenous, r);
for (set<pair<int, int> >::const_iterator it = r.begin(); it != r.end(); ++it)
if (dynamic_model->isNonstationary(it->first))
error("The deflator contains a non-stationary endogenous variable. This is not allowed. Please use only stationary endogenous and/or {log_}trend_vars.");
declared_nonstationary_vars.clear();
reset_data_tree();
}