rte-france / relife

ReLife is an open source Python library for asset management based on reliability theory and lifetime data analysis.
Apache License 2.0
17 stars 2 forks source link

Doubly censored data in the Kaplan-Meier estimator documentation #8

Open lisandrojim opened 2 years ago

lisandrojim commented 2 years ago

Hello,

I am fitting a Kaplan-Meier estimator with doubly censored data. But I get an error. To reproduce the error use the example below.

from relife.nonparametric import KaplanMeier as KM
km = KM()
km.fit(time=np.array([1,2,3]),event=np.array([1,0,2]))

The error is:

  File ~/relife/nonparametric.py:54 in _estimate
    raise ValueError("event values must be in [0,1]")
ValueError: event values must be in [0,1]

But the documentation says that event 2 is used to flag an event as left-censored.

tomguillon commented 2 years ago

Thank you for your comments. The Kaplan-Meier estimator cannot handle left censoring and right censoring. This is an error in the documentation that needs to be corrected. If you are interested in a non-parametric algorithm that takes into account all possible censorships, this is the Turnbull algorithm. It is planned to implement it in a future version.