ehrapy.tools.nelson_aalen¶
- ehrapy.tools.nelson_aalen(adata, duration_col, event_col)[source]¶
Employ the Nelson-Aalen estimator to estimate the cumulative hazard function from censored survival data
The Nelson-Aalen estimator is a non-parametric method used in survival analysis to estimate the cumulative hazard function. This technique is particularly useful when dealing with censored data, as it accounts for the presence of individuals whose event times are unknown due to censoring. By estimating the cumulative hazard function, the Nelson-Aalen estimator allows researchers to assess the risk of an event occurring over time, providing valuable insights into the underlying dynamics of the survival process. See https://lifelines.readthedocs.io/en/latest/fitters/univariate/NelsonAalenFitter.html
- Parameters:
adata (
AnnData
) – AnnData object with necessary columns duration_col and event_col.duration_col (
str
) – The name of the column in the AnnData objects that contains the subjects’ lifetimes.event_col (
str
) – The name of the column in anndata that contains the subjects’ death observation. If left as None, assume all individuals are uncensored.
- Return type:
NelsonAalenFitter
- Returns:
Fitted NelsonAalenFitter.
Examples
>>> import ehrapy as ep >>> adata = ep.dt.mimic_2(encoded=False) >>> # Flip 'censor_fl' because 0 = death and 1 = censored >>> adata[:, ["censor_flg"]].X = np.where(adata[:, ["censor_flg"]].X == 0, 1, 0) >>> naf = ep.tl.nelson_aalen(adata, "mort_day_censored", "censor_flg")