diff --git a/yli/survival.py b/yli/survival.py index b5d8586..046068e 100644 --- a/yli/survival.py +++ b/yli/survival.py @@ -224,7 +224,7 @@ def plot_survfunc_turnbull(ax, time_left, time_right, ci, step_loc=0.5, maxiter= return handle -def calc_survfunc_turnbull(time_left, time_right, ci, step_loc=0.5, maxiter=None, fail_prob_tolerance=None, se_method=None, zero_tolerance=None, transform_x=None, transform_y=None): +def calc_survfunc_turnbull(time_left, time_right, ci, step_loc=0.5, maxiter=None, ll_tolerance=None, se_method=None, zero_tolerance=None, transform_x=None, transform_y=None): # Estimate the survival function # Prepare arguments @@ -232,9 +232,9 @@ def calc_survfunc_turnbull(time_left, time_right, ci, step_loc=0.5, maxiter=None if maxiter: hpstat_args.append('--max-iterations') hpstat_args.append(str(maxiter)) - if fail_prob_tolerance: - hpstat_args.append('--fail-prob-tolerance') - hpstat_args.append(str(fail_prob_tolerance)) + if ll_tolerance: + hpstat_args.append('--ll-tolerance') + hpstat_args.append(str(ll_tolerance)) if se_method: hpstat_args.append('--se-method') hpstat_args.append(se_method) @@ -270,12 +270,17 @@ def calc_survfunc_turnbull(time_left, time_right, ci, step_loc=0.5, maxiter=None ypoints = transform_y(ypoints) if ci: - zstar = -stats.norm.ppf(config.alpha/2) - survival_prob_se = np.array(raw_result['survival_prob_se']) - # Get confidence intervals - ci0 = survival_prob - zstar * survival_prob_se - ci1 = survival_prob + zstar * survival_prob_se + if raw_result['survival_prob_se']: + zstar = -stats.norm.ppf(config.alpha/2) + survival_prob_se = np.array(raw_result['survival_prob_se']) + + ci0 = survival_prob - zstar * survival_prob_se + ci1 = survival_prob + zstar * survival_prob_se + else: + survival_prob_ci = np.array(raw_result['survival_prob_ci']) + ci0 = survival_prob_ci.T[0] + ci1 = survival_prob_ci.T[1] # Plot confidence intervals ypoints0 = np.concatenate([[1], ci0]).repeat(2)[:-1]