Search

Search papers and lessons

Kaplan–Meier Estimator

Level 4 · 10 min read

The Kaplan–Meier estimator builds a survival curve step by step from observed event times, using censored subjects for as long as they are at risk instead of throwing them away.

On this page

  • Colour = topic mix
  • Probability
  • Calculus
  • Discrete math
  • Inference
  • Sign in to see your progress

TL;DR

The Kaplan–Meier estimator answers a simple question: of the things being watched, what fraction are still going at each time? It moves forward through the observed times. At each time something fails, it multiplies the current survival fraction by the fraction of at-risk items that did not fail. Items that leave the study early, which are censored, count as at risk up to the moment they leave, so they are not thrown away.

Where you'll see it: in reliability studies of machine parts, in customer-retention curves, in clinical trial reports (educational explanation only; this is not medical advice), and as the standard first plot in any analysis of time-to-event data.

Intuition

A curve that only moves when something happens

Imagine following 6 light bulbs in a test rig. Some burn out, and you have to stop the test on others before they fail because the rig is needed elsewhere. Those stopped bulbs are censored: you know they lasted at least that long, but not when they would have failed.

A naive plot of "fraction still working" would be wrong if you drop the stopped bulbs. Dropping them throws away the bulbs that were known to survive at least that long, so the failures are compared against a smaller, unluckier group and the curve falls too fast. The fix is to keep the stopped bulbs in the count until they leave, and then to update only at moments when a bulb actually fails.

The survival curve is therefore flat between failures and steps down at each one. The size of each step depends on how many bulbs were still being watched at that moment.

Why a product of ratios

At any failure time, the question is: among the bulbs still being watched just before this moment, what fraction failed right now? If 1 out of 5 watched bulbs failed, the chance a watched bulb survives this moment is 4 out of 5. The survival chance to any later time is the product of these conditional survival chances across all earlier failure times. This is just the chain rule of probability applied to the sequence of moments.

The math

Setup

Let t1<t2<⋯<tKt_1 \lt t_2 \lt \dots \lt t_K be the distinct times at which at least one event happens. At time tjt_j:

  • njn_j is the number at risk: subjects still under observation and not yet failed, just before tjt_j. This includes those censored at exactly tjt_j.
  • djd_j is the number of events (failures) at tjt_j.

Definition

Definition: Kaplan–Meier estimator

The Kaplan–Meier estimate of the survival function is

S^(t)=∏j: tj≤t(1−djnj).\hat{S}(t) = \prod_{j:\, t_j \le t} \left(1 - \frac{d_j}{n_j}\right).

For tt before the first event, S^(t)=1\hat{S}(t) = 1. The estimate is constant between event times and drops at each tjt_j.

Each factor 1−dj/nj1 - d_j/n_j is the estimated probability of surviving time tjt_j, given survival up to just before it. The product is the chance of surviving through all the event times up to tt. Censoring only changes njn_j, by removing subjects who have left, so a censored subject contributes to the risk counts until the moment it is censored and then no further.

The median survival time

The estimated median is the smallest tt with S^(t)≤0.5\hat{S}(t) \le 0.5. If the curve never falls to 0.5 within the follow-up period, the median is not estimable and you should say so.

Uncertainty: Greenwood's formula

An approximate variance for S^(t)\hat{S}(t) is

Var^(S^(t))≈S^(t)2∑j: tj≤tdjnj (nj−dj).\widehat{\mathrm{Var}}\big(\hat{S}(t)\big) \approx \hat{S}(t)^2 \sum_{j:\, t_j \le t} \frac{d_j}{n_j\,(n_j - d_j)}.

This is Greenwood's formula. It is reliable when njn_j is not small. The standard error is its square root, and the usual confidence intervals are built on a log or log-log transform so that they stay inside [0,1][0, 1].

Why it is a maximum likelihood estimate

The estimator is the nonparametric maximum-likelihood estimate of the survival curve when the censoring does not depend on the outcome. Each factor is the empirical conditional probability of surviving a failure moment, so no distribution shape is assumed. That is the reason the method is called nonparametric.

0246800.20.40.60.81timeestimated survival
  • Kaplan–Meier estimate, example A
The curve is flat between event times and drops at each one. The censored subjects at 3 and 7 never cause a drop; they only shrink the at-risk count.

Worked examples

Example
Six subjects by hand

Six subjects are followed. Their times are: 2 (event), 3 (censored), 3 (event), 5 (event), 7 (censored), 8 (event). The censored subject at 3 is still at risk at time 3, so it counts in nn at that moment.

  1. At t=2t = 2: n=6n = 6, d=1d = 1. Factor 1−1/6=5/6≈0.83331 - 1/6 = 5/6 \approx 0.8333. Survival so far: 0.83330.8333.
  2. At t=3t = 3: n=5n = 5 (one left after the failure at 2), d=1d = 1 (the event; the censored subject does not fail). Factor 1−1/5=4/51 - 1/5 = 4/5. Survival: 0.8333×0.8=0.66670.8333 \times 0.8 = 0.6667.
  3. After t=3t = 3 the at-risk count is 5−2=35 - 2 = 3: one failed and one was censored.
  4. At t=5t = 5: n=3n = 3, d=1d = 1. Factor 1−1/3=2/31 - 1/3 = 2/3. Survival: 0.6667×0.6667=0.44440.6667 \times 0.6667 = 0.4444.
  5. After t=5t = 5 the at-risk count is 3−1=23 - 1 = 2. At t=7t = 7 the subject is censored, so the count becomes 11 and the curve does not move.
  6. At t=8t = 8: n=1n = 1, d=1d = 1. Factor 00. Survival falls to 00.
  7. The median is the first time the curve is at or below 0.50.5: that is t=5t = 5, where the estimate is 0.44440.4444.
  8. Greenwood's variance at t=5t = 5 sums the events so far: 16⋅5+15⋅4+13⋅2=0.0333+0.05+0.1667=0.25\frac{1}{6 \cdot 5} + \frac{1}{5 \cdot 4} + \frac{1}{3 \cdot 2} = 0.0333 + 0.05 + 0.1667 = 0.25. Then Var^≈0.44442×0.25=0.0494\widehat{\mathrm{Var}} \approx 0.4444^2 \times 0.25 = 0.0494, and the standard error is about 0.220.22. That is wide, because only six subjects were followed.
  9. Interpretation: about 44% are estimated to still be going at time 5, with a large uncertainty. The censored subject at 7 did not pull the curve down, but it did shrink the risk set for the last failure.
Example
Ties and a short test

Five units are tested. Their times are: 1 (event), 1 (event), 2 (censored), 4 (event), 5 (censored).

  1. At t=1t = 1: n=5n = 5, d=2d = 2. Two units failed together. Factor 1−2/5=3/5=0.61 - 2/5 = 3/5 = 0.6. Survival: 0.60.6.
  2. After t=1t = 1 the at-risk count is 33.
  3. At t=2t = 2, one unit is censored. The count drops to 22, but there is no drop in the curve.
  4. At t=4t = 4: n=2n = 2, d=1d = 1. Factor 1/21/2. Survival: 0.6×0.5=0.30.6 \times 0.5 = 0.3.
  5. The unit censored at 5 never causes a step. The curve stays at 0.30.3 from 4 onward.
  6. Median: the curve first reaches 0.50.5 or below at t=4t = 4.
  7. Greenwood sum at t=4t = 4: 25⋅3+12⋅1=0.1333+0.5=0.6333\frac{2}{5 \cdot 3} + \frac{1}{2 \cdot 1} = 0.1333 + 0.5 = 0.6333. Variance 0.09×0.6333=0.0570.09 \times 0.6333 = 0.057, standard error about 0.240.24.
  8. Interpretation: with two failures at the same moment, the single step is larger than either one would be alone. The tail of the curve rests on only two units at risk, which is why its uncertainty is large.

Tradeoffs and failure modes

The estimator is simple and assumption-light, but it has conditions. Check them before reading the curve as the truth.

SituationProblemBetter choice
Censoring depends on the outcome (for example, the sickest subjects leave first)Curve is biased in a direction you cannot seeModel the censoring, or report the limitation
Very few subjects still at risk late in follow-upTail is unstable and its interval is very wideReport the at-risk count next to the curve and truncate the plot
You need to compare two groups formallyTwo separate curves do not give a testLog-rank test on the same data
You need predictions beyond the observed rangeCurve stops where the data stopParametric survival model (Weibull, exponential) with its assumptions stated
Many distinct times with one subject eachWorks as intended, but the step plot is busyKeep the plot, or summarise with survival at chosen times
Times are recorded coarsely (days, years)Many ties distort the stepsAccept the approximation or use a method for grouped times

Practical warnings:

  • Do not read the last step as precise. The curve's end depends on a handful of subjects.
  • Report the number at risk under the plot. It is the most honest part of the figure.
  • The estimate describes this study. It is not a population law unless the sample represents the population.

History

Edward Kaplan and Paul Meier published the estimator in 1958, in the Journal of the American Statistical Association, under the title "Nonparametric Estimation from Incomplete Observations". They were working on how to estimate survival when some observations are incomplete, and they showed that the product of conditional survival fractions is a natural estimator that uses every observation for as long as it is informative.

The variance formula is usually credited to Major Greenwood, who worked on life tables in the 1920s. The method spread quickly through medical statistics and reliability engineering because it needed no distributional assumption and could be computed by hand from a list of times. Its wide use today comes from that simplicity together with the honest handling of censoring.

Check yourself

QuestionWhich subjects in the six-subject example count toward nn at time 3, and why?Show answer

The subject that failed at time 2 has left the risk set. The censored subject at 3 and the subject who fails at 3 are still under observation just before time 3, so both count toward n=5n = 5. The censored subject counts because it was still being watched at that moment; it only leaves the risk set after time 3.

QuestionCompute S^(3)\hat{S}(3) for the data 2 (event), 3 (censored), 3 (event), 5 (event), 7 (censored), 8 (event).Show answer

The product over event times up to 3 is (1−1/6)(1−1/5)=(5/6)(4/5)=2/3≈0.6667(1 - 1/6)(1 - 1/5) = (5/6)(4/5) = 2/3 \approx 0.6667.

QuestionWhy is it wrong to drop censored subjects from the data before computing the curve?Show answer

Dropping them removes the information that those subjects survived up to their censoring time, so at-risk counts shrink too early. The curve then falls too fast, by an amount that depends on when subjects happened to leave rather than on their actual survival. The censored subject should stay in nn until its censoring time.

QuestionA study of 40 machine parts reports a Kaplan–Meier curve that reaches 0.5 at time 800 hours, with only 3 parts still under observation after 700 hours. What should you say about the reported median?Show answer

The median is estimated from the data but its uncertainty is large, since only 3 parts were still at risk when the curve crossed 0.5. The right statement is that the median is roughly 800 hours with a wide interval, and the curve after 700 hours rests on very few units. Reporting the at-risk count alongside the curve lets a reader see this.

Sources