sksurv.nonparametric.kaplan_meier_estimator

sksurv.nonparametric.kaplan_meier_estimator(event, time_exit, time_enter=None, time_min=None)

Kaplan-Meier estimator of survival function.

Parameters:
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.

Returns:
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.

References

[1]Kaplan, E. L. and Meier, P., “Nonparametric estimation from incomplete observations”, Journal of The American Statistical Association, vol. 53, pp. 457-481, 1958.

Examples

Creating a Kaplan-Meier curve:

>>> x, y = kaplan_meier_estimator(event, time)
>>> plt.step(x, y, where="post")
>>> plt.ylim(0, 1)
>>> plt.show()