CamDavidsonPilon / lifelines

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

Percentile CI and Percentile NHST #438

Open CamDavidsonPilon opened 6 years ago

CamDavidsonPilon commented 6 years ago

https://stats.stackexchange.com/questions/336873/how-to-calculate-the-confidence-interval-around-difference-in-median-survival-ti

pzivich commented 6 years ago

Sure. You would resample with replacement for each group, fit a KM, get median survival, then repeat. One issue with that particular example though is the sample size is a little small, bootstrapping is a large sample method. There are a few ways to get the CI after, but I would advocate for taking the 2.5th and 97.5th percentiles to get the 95% CI

As far as I know, this doesn't violate the regularity assumptions of bootstrapping, and as long as all data is independent its fine. Violating of the regularity assumption occurs in machine learning approaches

pzivich commented 6 years ago

Although, you don't really even need to do bootstrapping. You could take the median estimate of both groups, the number in each group, and the standard error from Greenwood's formula. From these items you can just directly get the 95% CI of the difference in median survival times. Again, a large sample method

CamDavidsonPilon commented 6 years ago

This is a good start for more general CI for percentiles: http://www.mas.ncl.ac.uk/~nmf16/teaching/mas3311/week07.pdf

bayesfactor commented 5 years ago

One question: if the RMST method isn't yet supported in lifelines, what is the preferred method to statistically compare survival of 2 different groups?

CamDavidsonPilon commented 5 years ago

Probably the statistics.logrank_test - but if you are interested in comparing at a precise point in time, then statistics.survival_difference_at_fixed_point_in_time_test.