2

I have been using Lifelines library for survival analysis.

I observed a difference in the plots using the Kaplan Meieir Fitter estimator on my data.

enter image description here

The above plot of the data, provides a step function using the KMF estimator.

While calling kmf.survival_function_.plot(), it provides the following plot: enter image description here

I was of the impression that both the plots should produce the same results. If not, is there a difference between the survival function and the KMF estimator?

Why does one plot produces a straight curve while the other produces a step function?

I quote from the Lifelines docs: "Alternatively, we can call plot on the KaplanMeierFitter itself to plot both the KM estimate and its confidence intervals:"

Doesn't this mean both the plots should be the same? Can someone point out what I am missing here?

Cam.Davidson.Pilon
  • 11,476
  • 5
  • 47
  • 75
keshr3106
  • 35
  • 1
  • 8
  • I was not able to post more than 2 links. For more clarity, the Lifelines docs I quoted is at: http://lifelines.readthedocs.org/en/latest/Intro%20to%20lifelines.html#estimating-the-survival-function-using-kaplan-meier – keshr3106 Oct 03 '15 at 16:48

1 Answers1

3

I'm the author of lifelines. The different is only visual: the latter graph uses Pandas' built-in plotting library (as survival_function_ is a Pandas dataframe), whereas the former graph is an internal lifelines plotting graph, which includes confidence intervals and a step-wise visualization (which I feel is more appropriate for kaplan-meier estimates).

Does that clear things up?

Cam.Davidson.Pilon
  • 11,476
  • 5
  • 47
  • 75
  • Hey @Cam.Davidson.Pilon, thanks a lot for replying - I understand the difference now, but what I still don't get is that in the documentation, kmf.plot() used in the examples provide a smooth function like the latter graph above while my data gives a step function for the same method call . Is the difference due to the data being modelled? Is there any way to use the arguments 'show_censors', 'ci_show' on the smooth graph as these arguments can't be used with the Pandas' built-in plotting library? – keshr3106 Oct 03 '15 at 22:09
  • docs are out of date it seems! I'll have to update. Do you want a smooth graph over a step graph? – Cam.Davidson.Pilon Oct 04 '15 at 04:33
  • Hey @Cam.Davidson.Pilon, The docs show the smooth graphs having confidence intervals and censor information but it is actually not possible to do so using the library. I suggest the docs be updated to show the step function than the smooth functions. And, it will be great if there is a way to actually enable smooth graphs having confidence intervals and censor information. Is it necessary to open an issue formally on Github? Thanks a lot for replying! – keshr3106 Oct 05 '15 at 01:01
  • Yea, please open an issue, that way I'll remember – Cam.Davidson.Pilon Oct 05 '15 at 01:27