sksurv.nonparametric.nelson_aalen_estimator#
- sksurv.nonparametric.nelson_aalen_estimator(event, time)[source]#
Computes the Nelson-Aalen estimate of the cumulative hazard function.
See [1], [2] for further description.
- Parameters:
event (array-like, shape = (n_samples,)) – A boolean array where
Trueindicates an event andFalseindicates right-censoring.time (array-like, shape = (n_samples,)) – Time of event or censoring.
- Returns:
time (ndarray, shape = (n_times,)) – Unique times.
cum_hazard (ndarray, shape = (n_times,)) – Cumulative hazard at each unique time point.
Examples
Creating a cumulative hazard curve:
>>> import matplotlib.pyplot as plt >>> from sksurv.datasets import load_aids >>> from sksurv.nonparametric import nelson_aalen_estimator >>> >>> _, y = load_aids(endpoint="death") >>> time, cum_hazard = nelson_aalen_estimator(y["censor_d"], y["time_d"]) >>> >>> plt.step(time, cum_hazard, where="post") [...] >>> plt.show()
References