Preprocessor: fix crash when mean or stderr of an estimated parameter is specified as an expression instead of a plain value (bug introduced in 28d30d9a62
)
parent
9cf9df4b63
commit
c3608b9ba7
|
@ -362,12 +362,20 @@ EstimatedParamsStatement::checkPass(ModFileStructure &mod_file_struct)
|
||||||
if (it->name == "dsge_prior_weight")
|
if (it->name == "dsge_prior_weight")
|
||||||
mod_file_struct.dsge_prior_weight_in_estimated_params = true;
|
mod_file_struct.dsge_prior_weight_in_estimated_params = true;
|
||||||
|
|
||||||
|
// Handle case of degenerate beta prior
|
||||||
if (it->prior == "1") //BETA_PDF is associated with "1" in DynareBison.yy
|
if (it->prior == "1") //BETA_PDF is associated with "1" in DynareBison.yy
|
||||||
if (dynamic_cast<NumConstNode *>(it->mean)->isNumConstNodeEqualTo(0.5) &&
|
try
|
||||||
dynamic_cast<NumConstNode *>(it->std)->isNumConstNodeEqualTo(0.5))
|
|
||||||
{
|
{
|
||||||
cerr << "ERROR: The prior density is not defined for the beta distribution when the mean = standard deviation = 0.5." << endl;
|
if (it->mean->eval(eval_context_type()) == 0.5 &&
|
||||||
exit(EXIT_FAILURE);
|
it->std->eval(eval_context_type()) == 0.5)
|
||||||
|
{
|
||||||
|
cerr << "ERROR: The prior density is not defined for the beta distribution when the mean = standard deviation = 0.5." << endl;
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (ExprNode::EvalException &e)
|
||||||
|
{
|
||||||
|
// We don't have enough information to compute the numerical value, skip the test
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue