ehrapy.tools.weibull_aft¶
- ehrapy.tools.weibull_aft(adata, duration_col, event_col, entry_col=None)[source]¶
Fit the Weibull accelerated failure time regression for the survival function.
The Weibull Accelerated Failure Time (AFT) survival regression model is a statistical method used to analyze time-to-event data, where the underlying assumption is that the logarithm of survival time follows a Weibull distribution. It models the survival time as an exponential function of the predictors, assuming a specific shape parameter for the distribution and allowing for accelerated or decelerated failure times based on the covariates. See https://lifelines.readthedocs.io/en/latest/fitters/regression/WeibullAFTFitter.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 anndata that contains the subjects’ death observation. If left as None, assume all individuals are uncensored.entry_col (
str
) – Column denoting when a subject entered the study, i.e. left-truncation.
- Return type:
WeibullAFTFitter
- Returns:
Fitted WeibullAFTFitter
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) >>> aft = ep.tl.weibull_aft(adata, "mort_day_censored", "censor_flg")