KaplanMeier#

class relife.KaplanMeier[source]#

Kaplan-Meier estimator.

Compute the non-parametric Kaplan-Meier estimator (also known as the product limit estimator) of the survival function from lifetime data.

Notes

For a given time instant \(t\) and \(n\) total observations, this estimator is defined as:

\[\hat{S}(t) = \prod_{i: t_i \leq t} \left( 1 - \frac{d_i}{n_i}\right)\]

where \(d_i\) is the number of failures until \(t_i\) and \(n_i\) is the number of assets at risk just prior to \(t_i\).

The variance estimation is obtained by:

\[\widehat{Var}[\hat{S}(t)] = \hat{S}(t)^2 \sum_{i: t_i \leq t} \frac{d_i}{n_i(n_i - d_i)}\]

which is often referred to as Greenwood’s formula.

References

[1]

Lawless, J. F. (2011). Statistical models and methods for lifetime data. John Wiley & Sons.

[2]

Kaplan, E. L., & Meier, P. (1958). Nonparametric estimation from incomplete observations. Journal of the American statistical association, 53(282), 457-481.

Methods

fit

Compute the non-parametric estimations with respect to lifetime data.

sf

Survival function.

Attributes

plot

estimates

fit(time, event=None, entry=None, departure=None, inplace=False)[source]#

Compute the non-parametric estimations with respect to lifetime data.

Parameters:
timendarray (1d or 2d)

Observed lifetime values.

eventndarray of boolean values (1d), default is None

Boolean indicators tagging lifetime values as right censored or complete.

entryndarray of float (1d), default is None

Left truncations applied to lifetime values.

departurendarray of float (1d), default is None

Right truncations applied to lifetime values.

inplaceboolean, default is True

If true, estimations are stored in the object

sf(time)[source]#

Survival function.

Parameters:
timenp.ndarray of shape (n, )

The times at which to estimate the survival function.

Returns:
np.ndarray of shape (n, )

The estimated survival probabilities at each time.