ehrapy.tools.weibull

ehrapy.tools.weibull(adata, duration_col, event_col)[source]

Employ the Weibull model in univariate survival analysis to understand event occurrence dynamics.

In contrast to the non-parametric Nelson-Aalen estimator, the Weibull model employs a parametric approach with shape and scale parameters, enabling a more structured analysis of survival data. 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 fitting the Weibull model to censored survival data, researchers can estimate these parameters and gain insights into the hazard rate over time, facilitating comparisons between different groups or treatments. This method provides a comprehensive framework for examining survival data and offers valuable insights into the factors influencing event occurrence dynamics. See https://lifelines.readthedocs.io/en/latest/fitters/univariate/WeibullFitter.html

Parameters:
  • adata (AnnData) – adata: AnnData object with necessary columns duration_col and event_col.

  • duration_col (str) – Name of the column in the AnnData objects that contains the subjects’ lifetimes.

  • event_col (str) – Name of the column in the AnnData object that contains the subjects’ death observation. If left as None, assume all individuals are uncensored.

Return type:

WeibullFitter

Returns:

Fitted WeibullFitter

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)
>>> wf = ep.tl.weibull(adata, "mort_day_censored", "censor_flg")