turnbull: Gracefully handle the case where ICM does not increase the log-likelihood
This commit is contained in:
parent
606c1636e0
commit
c67965478d
@ -513,11 +513,10 @@ fn do_icm_step(data: &TurnbullData, p: &Vec<f64>, s: &Vec<f64>, ll_tolerance: f6
|
||||
|
||||
step_size_exponent += 1;
|
||||
|
||||
// FIXME: Nasty hack!
|
||||
// Limit of 10 should be good enough, but sometimes ICM step does not work well when constrained so the limit is increased
|
||||
// It would be greatly preferable to simply handle this case more gracefully when constrained
|
||||
if step_size_exponent > 100 {
|
||||
panic!("ICM fails to increase log-likelihood");
|
||||
if step_size_exponent > 10 {
|
||||
// If ICM does not increase log-likelihood, then simply return the original estimate and retry EM again
|
||||
// If neither increases the log-likelihood, then we will have have converged within fit_turnbull_estimator
|
||||
return (p.clone(), s.clone(), ll_model);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -639,6 +638,9 @@ fn survival_prob_likelihood_ratio_ci(data: &TurnbullData, progress_bar: Progress
|
||||
ci_bound_upper = ci_estimate;
|
||||
}
|
||||
|
||||
// FIXME: Sometimes this does not converge within max_iterations - investigate why this is
|
||||
// If it is not an issue with the algorithm, then we should also terminate if width of interval is narrower than a specified tolerance
|
||||
|
||||
ci_estimate = (ci_bound_lower + ci_bound_upper) / 2.0;
|
||||
|
||||
iteration += 1;
|
||||
|
Loading…
Reference in New Issue
Block a user