some initialization improvements for GG
@@ -100,7 +100,7 @@ class GeneralizedGammaFitter(KnownModelParametricUnivariateFitter):
_fitted_parameter_names = ["mu_", "ln_sigma_", "lambda_"]
_bounds = [(None, None), (None, None), (None, None)]
_compare_to_values = np.array([0.0, 0.0, 1.0])
- _scipy_fit_options = {"ftol": 1e-20}
+ _scipy_fit_options = {"ftol": 1e-7}
def _create_initial_point(self, Ts, E, *args):
if CensoringType.is_right_censoring(self):
@@ -108,8 +108,9 @@ class GeneralizedGammaFitter(KnownModelParametricUnivariateFitter):
elif CensoringType.is_left_censoring(self):
log_data = log(Ts[1])
elif CensoringType.is_interval_censoring(self):
- log_data = log(Ts[1] - Ts[0])
- return np.array([log_data.mean(), log(log_data.std()), 0.1])
+ # this fails if Ts[1] == Ts[0], so we add a some fudge factors.
+ log_data = log(Ts[1] - Ts[0] + 0.01)
+ return np.array([log_data.mean(), log(log_data.std() + 0.01), 0.1])
def _survival_function(self, params, times):
mu_, ln_sigma_, lambda_ = params
