kaplan_meier_estimator(event, time_exit, time_enter=None, time_min=None, reverse=False)¶
Kaplan-Meier estimator of survival function.
See 1 for further description.
event (array-like, shape = (n_samples,)) – Contains binary event indicators.
time_exit (array-like, shape = (n_samples,)) – Contains event/censoring times.
time_enter (array-like, shape = (n_samples,), optional) – Contains time when each individual entered the study for left truncated survival data.
time_min (float, optional) – Compute estimator conditional on survival at least up to the specified time.
reverse (bool, optional, default: False) – Whether to estimate the censoring distribution. When there are ties between times at which events are observed, then events come first and are subtracted from the denominator. Only available for right-censored data, i.e. time_enter must be None.
time (array, shape = (n_times,)) – Unique times.
prob_survival (array, shape = (n_times,)) – Survival probability at each unique time point. If time_enter is provided, estimates are conditional probabilities.
Creating a Kaplan-Meier curve:
>>> x, y = kaplan_meier_estimator(event, time) >>> plt.step(x, y, where="post") >>> plt.ylim(0, 1) >>> plt.show()
Kaplan, E. L. and Meier, P., “Nonparametric estimation from incomplete observations”, Journal of The American Statistical Association, vol. 53, pp. 457-481, 1958.