CamDavidsonPilon / lifelines

Survival analysis in Python
lifelines.readthedocs.org
MIT License
2.34k stars 555 forks source link

New feature request: Add smoothed Kaplan-Meier plot #942

Open alonsosilvaallende opened 4 years ago

alonsosilvaallende commented 4 years ago

New feature request. It would be nice to add the possibility to have a smoothed Kaplan-Meier plot instead of the steps plot currently used. I'm thinking something similar to this.

arturomoncadatorres commented 4 years ago

I suggested something similar in #670. Doing a proper smoothing (as suggested by O'Keese et al.,) could help confidentialising the KM curves and contribute to protecting the privacy of individual data points (which very often correspond to patients).

CamDavidsonPilon commented 4 years ago

hmm never thought about this (sorry about dropping both these issues). Are ya'll thinking of just smoothing the plot, or also the attributes like survival_function_?

arturomoncadatorres commented 4 years ago

(No problem!)

From my side and at least on the KM case, I was thinking on just smoothing the curve when plotting.

Further measures for confidentialising the curve could include:

These would also be restricted exclusively to the display (i.e., plot). On top of my head, kmf.plot could have an additional boolean parameter confidential that when True, applies these three (or however) options when plotting.

alonsosilvaallende commented 4 years ago

In my case, just smoothing the curve would be enough.

alonsosilvaallende commented 4 years ago

I found a library (PySurvival) which implements Smooth Kaplan-Meier. The code can be found here.