Improvements to the test for balanced growth path
— Raise the default tolerance for cross-derivatives to 1e-6, to reduce the number of false positives — New option “balanced_growth_test_tol” to the “model” block for changing that tolerance — Turn back test failures into errors. Since there is now an option for controlling the tolerance, the user always has the possibility of making the test pass. Closes: dynare#1389issue#70
parent
0f0299bc1c
commit
5a5817b4fe
|
@ -100,6 +100,7 @@ DynamicModel::DynamicModel(const DynamicModel &m) :
|
|||
ModelTree {m},
|
||||
trend_component_model_table {m.trend_component_model_table},
|
||||
var_model_table {m.var_model_table},
|
||||
balanced_growth_test_tol {m.balanced_growth_test_tol},
|
||||
static_only_equations_lineno {m.static_only_equations_lineno},
|
||||
static_only_equations_equation_tags {m.static_only_equations_equation_tags},
|
||||
deriv_id_table {m.deriv_id_table},
|
||||
|
@ -160,6 +161,7 @@ DynamicModel::operator=(const DynamicModel &m)
|
|||
|
||||
assert(&trend_component_model_table == &m.trend_component_model_table);
|
||||
assert(&var_model_table == &m.var_model_table);
|
||||
balanced_growth_test_tol = m.balanced_growth_test_tol;
|
||||
|
||||
static_only_equations_lineno = m.static_only_equations_lineno;
|
||||
static_only_equations_equation_tags = m.static_only_equations_equation_tags;
|
||||
|
@ -5800,13 +5802,14 @@ DynamicModel::testTrendDerivativesEqualToZero(const eval_context_t &eval_context
|
|||
if (symbol_table.getType(endogit->first.first) == SymbolType::endogenous)
|
||||
{
|
||||
double nearZero = testeq->getDerivative(endogit->second)->eval(eval_context); // eval d F / d Trend d Endog
|
||||
if (fabs(nearZero) > zero_band)
|
||||
if (fabs(nearZero) > balanced_growth_test_tol)
|
||||
{
|
||||
cerr << "WARNING: trends not compatible with balanced growth path; the second-order cross partial of equation " << eq + 1 << " (line "
|
||||
cerr << "ERROR: trends not compatible with balanced growth path; the second-order cross partial of equation " << eq + 1 << " (line "
|
||||
<< equations_lineno[eq] << ") w.r.t. trend variable "
|
||||
<< symbol_table.getName(it->first.first) << " and endogenous variable "
|
||||
<< symbol_table.getName(endogit->first.first) << " is not null. " << endl;
|
||||
// Changed to warning. See discussion in #1389
|
||||
<< symbol_table.getName(endogit->first.first) << " is not null (abs. value = "
|
||||
<< fabs(nearZero) << "). If you are confident that your trends are correctly specified, you can raise the value of option 'balanced_growth_test_tol' in the 'model' block." << endl;
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,7 +35,15 @@ public:
|
|||
TrendComponentModelTable &trend_component_model_table;
|
||||
//! A reference to the VAR model table
|
||||
VarModelTable &var_model_table;
|
||||
/* Used in the balanced growth test, for determining whether the
|
||||
cross-derivative of a given equation, w.r.t. an endogenous and a trend
|
||||
variable is zero. Controlled by option “balanced_growth_test_tol” of the
|
||||
“model” block. The default should not be too small (see dynare#1389). */
|
||||
double balanced_growth_test_tol{1e-6};
|
||||
private:
|
||||
/* Used in the balanced growth test, for skipping equations where the test
|
||||
cannot be performed (i.e. when LHS=RHS at the initial values). Should not
|
||||
be too large, otherwise the test becomes less powerful. */
|
||||
constexpr static double zero_band{1e-8};
|
||||
|
||||
//! Stores equations declared as [static]
|
||||
|
|
|
@ -73,7 +73,7 @@ class ParsingDriver;
|
|||
}
|
||||
|
||||
%token AIM_SOLVER ANALYTIC_DERIVATION ANALYTIC_DERIVATION_MODE AR POSTERIOR_SAMPLING_METHOD
|
||||
%token BAYESIAN_IRF BETA_PDF BLOCK USE_CALIBRATION SILENT_OPTIMIZER
|
||||
%token BALANCED_GROWTH_TEST_TOL BAYESIAN_IRF BETA_PDF BLOCK USE_CALIBRATION SILENT_OPTIMIZER
|
||||
%token BVAR_DENSITY BVAR_FORECAST NODECOMPOSITION DR_DISPLAY_TOL HUGE_NUMBER FIG_NAME WRITE_XLS
|
||||
%token BVAR_PRIOR_DECAY BVAR_PRIOR_FLAT BVAR_PRIOR_LAMBDA INTERACTIVE SCREEN_SHOCKS STEADYSTATE
|
||||
%token BVAR_PRIOR_MU BVAR_PRIOR_OMEGA BVAR_PRIOR_TAU BVAR_PRIOR_TRAIN DETAIL_PLOT TYPE
|
||||
|
@ -900,6 +900,7 @@ model_options : BLOCK { driver.block(); }
|
|||
| o_linear
|
||||
| PARALLEL_LOCAL_FILES EQUAL '(' parallel_local_filename_list ')'
|
||||
| LINEAR_DECOMPOSITION { driver.linear_decomposition(); }
|
||||
| BALANCED_GROWTH_TEST_TOL EQUAL non_negative_number { driver.balanced_growth_test_tol($3); }
|
||||
;
|
||||
|
||||
model_options_list : model_options_list COMMA model_options
|
||||
|
|
|
@ -706,6 +706,7 @@ DATE -?[0-9]+([ya]|m([1-9]|1[0-2])|q[1-4]|w([1-9]{1}|[1-4][0-9]|5[0-2]))
|
|||
<DYNARE_BLOCK>periods {return token::PERIODS;}
|
||||
<DYNARE_BLOCK>cutoff {return token::CUTOFF;}
|
||||
<DYNARE_BLOCK>mfs {return token::MFS;}
|
||||
<DYNARE_BLOCK>balanced_growth_test_tol {return token::BALANCED_GROWTH_TEST_TOL;}
|
||||
<DYNARE_BLOCK>gamma_pdf {return token::GAMMA_PDF;}
|
||||
<DYNARE_BLOCK>beta_pdf {return token::BETA_PDF;}
|
||||
<DYNARE_BLOCK>normal_pdf {return token::NORMAL_PDF;}
|
||||
|
|
|
@ -793,6 +793,12 @@ ParsingDriver::mfs(const string &value)
|
|||
mod_file->static_model.mfs = val;
|
||||
}
|
||||
|
||||
void
|
||||
ParsingDriver::balanced_growth_test_tol(const string &value)
|
||||
{
|
||||
mod_file->dynamic_model.balanced_growth_test_tol = stod(value);
|
||||
}
|
||||
|
||||
void
|
||||
ParsingDriver::end_initval(bool all_values_required)
|
||||
{
|
||||
|
|
|
@ -356,6 +356,8 @@ public:
|
|||
void cutoff(const string &value);
|
||||
//! mfs option of model block
|
||||
void mfs(const string &value);
|
||||
//! balanced_growth_test_tol option of model block
|
||||
void balanced_growth_test_tol(const string &value);
|
||||
//! Sets the FILENAME for the initial value in initval
|
||||
void initval_file(const string &filename);
|
||||
//! Declares an endogenous variable
|
||||
|
|
Loading…
Reference in New Issue