Closed bennoleslie closed 7 years ago
The most basic way is to not modify anything and do:
kmf.fit(T, E)
(1-kmf.survival_function_).plot()
If you wanted to use the internal lifelines plotting library, then I'm afraid it's a bit more complicated.
That is neat, I hadn't realised that this object was directly plot-able like that.
Unfortunately though I'm now quite attached to all the niceties of the lifelines plotting library, so I'm not sure I can see a good alternative that wouldn't.
The next best that I came up with is this:
class Failure:
def __init__(self, kmf):
self.failure_function_ = 1 - kmf.survival_function_
self.confidence_interval_ = 1 - kmf.confidence_interval_
self.plot = plotting.plot_estimate(self, 'failure_function_')
Failure(kmf).plot()
Which seems like it works, but I'm not 100% sure about the 1 - kmf.confidence_interval_
part.
Is there any interest in having the KaplanMeierFitter class directly fit the failure function rather than the survival function, or is that simply not a useful thing in general?
I think it's a small jump for the user to create this. However adding it to KaplanMeierFitter would complicate the API further, so I am voting to close this. Thanks for the issue however!
I'd like to be able to plot the F(t) rather than S(t) as it is a more informative way at looking at the data in my use case.
It's not clear what the best way of doing this would be with the current API. I ended up modifying the
Is there a more straight forward way of achieving this?