CamDavidsonPilon / lifelines

Survival analysis in Python
lifelines.readthedocs.org
MIT License
2.35k stars 557 forks source link

Weibull AFT Fitter - Check PH Assumptions fails #999

Open aysrivastava94 opened 4 years ago

aysrivastava94 commented 4 years ago

Hi,

While trying the Weibull AFT Fitter, I used the 'check_assumptions' method to verify the PH assumption. I got the error "TypeError: compute_residuals() got an unexpected keyword argument 'kind'". Can you help me with this?

Also, I noticed that the package API reference (on lifelines documentation website) for WeibullAFTFitter() uses CoxPHFitter() for the check_assumptions method. Is there any difference in the method syntax between the method of the two fitters?

Code:

# Data preparation
import lifelines
from lifelines import datasets
lung_dataset = datasets.load_lung().dropna()
lung_dataset['event'] = lung_dataset['status']-1

# Best fit check
lifelines.utils.find_best_parametric_model(lung_dataset['time'],lung_dataset['event'])
# Result recommends WeibullFitter - Hence, going ahead with WeibullAFTFitter

#Fitting the model
WeibullAFT = lifelines.WeibullAFTFitter().fit(lung_dataset.drop('status', axis = 1), duration_col = 'time',event_col = 'event')
#Assumption check
WeibullAFT.check_assumptions(lung_dataset.drop('status', axis = 1))

Thanks

CamDavidsonPilon commented 4 years ago

Must be a bug - will fix in the next release!

CamDavidsonPilon commented 4 years ago

Anyways, I haven't implemented residuals for Weibull AFT model yet, so this test isn't available yet unfortunately.