The Kaplan–Meier Estimator

How to estimate a survival function when many lives are still being watched at the end of a study. Derives the Kaplan–Meier estimator as a product of conditional probabilities and proves that it is the nonparametric maximum likelihood estimate; proves that without censoring it is the empirical survival function, with Greenwood's variance reducing to the binomial one; derives the Nelson–Aalen estimator of the cumulative hazard, proves that the Kaplan–Meier curve never lies above its exponential, and proves in discrete time, by a martingale argument, the exact mean and variance of the error of the Nelson–Aalen estimator; derives Greenwood's formula by the delta method, saying which step is heuristic, and the plain, log and log-log intervals; and treats the tail of the curve, the median and its Brookmeyer–Crowley interval, and what the estimator converges to when censoring is informative. Worked on the 6-MP leukemia trial and on twenty years of NHANES mortality follow-up by diagnosed diabetes, with simulations of interval coverage and of bias under informative censoring (30 seeds). Worked problems on a log-log interval by hand, Kaplan–Meier against the exponential of Nelson–Aalen, the median's interval, and an estimate with censored observations in the middle.

Of the 5,219 adults examined by NHANES in 2017 and 2018 whose records were linked to the National Death Index, 116 had died by the end of 2019. That is 2.22% of them. Yet 2.22% is not the chance that an adult died within three years of the examination. About half of the adults had been examined less than two years before the end of 2019, so a death in their third year could not yet have been seen. How do we estimate the chance of surviving three years, or twenty, from people who have been watched for different lengths of time?

The Kaplan–Meier estimator answers it. It estimates the survival function $S(t) = P(T > t)$ of a lifetime $T$. In the data some lifetimes are known exactly, and others are known only to exceed the time at which observation stopped. Kaplan and Meier (1958) called it the product-limit estimate. Their abstract states the property that makes it canonical: it is "the distribution, unrestricted as to form, which maximizes the likelihood of the observations".

First we build the estimator as a product of conditional probabilities and compute it by hand on a small clinical trial. Then we prove that it is the nonparametric maximum likelihood estimate and that, without censoring, it is the ordinary share of survivors. Next come the Nelson–Aalen estimator of the cumulative hazard and the variance of both estimators: exact in discrete time for Nelson–Aalen, by the delta method for Kaplan–Meier. Three kinds of confidence interval follow, then the tail of the curve and the median. Finally we apply it to twenty years of NHANES follow-up and ask what it estimates when censoring is not independent. The article assumes Censoring, Survival Functions and Hazards, which defines the hazard, the cumulative hazard and independent censoring and derives the likelihood of censored data. It also uses The Delta Method and Conditional Expectation.

Notation

Each of $n$ people has a lifetime $T_i$ and a censoring time $C_i$. We observe $Y_i = \min(T_i, C_i)$ and the event indicator $\delta_i = \mathbf{1}\{T_i \le C_i\}$, which is 1 when the death (or other event) was seen and 0 when the observation was censored. The distinct times at which events were seen are $t_{(1)} < t_{(2)} < \cdots < t_{(k)}$. At $t_{(j)}$, $d_j$ is the number of events and $n_j$ the number at risk, the people with $Y_i \ge t_{(j)}$. A person censored at exactly $t_{(j)}$ is counted at risk there: by convention the event comes first. The discrete hazard at $t_{(j)}$ is $h_j = P(T = t_{(j)} \mid T \ge t_{(j)})$. The cumulative hazard is $H(t)$, the censoring survival function $G(t) = P(C > t)$, and independent censoring means that $T$ and $C$ are independent. All of these are defined in Censoring, Survival Functions and Hazards.

The estimator as a product of conditional probabilities

Here is the idea in one sentence. Surviving past $t$ means surviving each event time up to $t$ in turn, so $S(t)$ is a product of conditional survival probabilities. Each of those can be estimated from the people still under observation at that time, whatever happened to the others.

Between event times nothing happens that the data can see, so only the event times matter. For a lifetime whose distribution puts its mass at the event times, the chain rule of conditional probability gives

$$S(t) = P(T > t) = \prod_{j:\, t_{(j)} \le t} P\big(T > t_{(j)} \mid T \ge t_{(j)}\big) = \prod_{j:\, t_{(j)} \le t} (1 - h_j).$$

Censoring, Survival Functions and Hazards proves this product formula for any discrete distribution (Theorem 2 there). At $t_{(j)}$ there are $n_j$ people known to be alive and under observation, and $d_j$ of them die. Under independent censoring, being still under observation says nothing about one's risk at $t_{(j)}$, so the natural estimate of $h_j$ is $\hat h_j = d_j/n_j$. Multiplying the estimated factors gives

$$\hat S(t) = \prod_{j:\, t_{(j)} \le t}\Big(1 - \frac{d_j}{n_j}\Big),$$

a step function that is 1 before the first event, drops at each event time and stays flat in between. A censored observation never causes a drop. It leaves the risk set, so every later factor is computed from fewer people.

The estimate is defined only up to the largest observation $y_{\max}$. If that observation is an event and everyone still at risk dies, $\hat S$ reaches 0 there. If it is censored, $\hat S$ stops at a positive value, and the data say nothing about what happens next. The section "The tail of the curve" returns to this.

The estimator on a small trial

Freireich et al. (1963) randomized children with acute leukemia in remission to 6-mercaptopurine (6-MP) or placebo and recorded the length of remission in weeks. The 21 placebo patients all relapsed, at 1, 1, 2, 2, 3, 4, 4, 5, 5, 8, 8, 8, 8, 11, 11, 12, 12, 15, 17, 22 and 23 weeks. Of the 21 patients on 6-MP, 9 relapsed and 12 were censored. Their times are 6, 6, 6, 6+, 7, 9+, 10, 10+, 11+, 13, 16, 17+, 19+, 20+, 22, 23, 25+, 32+, 32+, 34+ and 35+, where + marks a censored time. The values are taken from two independent distributions of the dataset, which agree (the script names them); the original paper was not available to check them against.

For the 6-MP group the computation runs as follows; the standard error column is Greenwood's, derived below.

$t_{(j)}$ $n_j$ $d_j$ $1 - d_j/n_j$ $\hat S(t_{(j)})$ standard error
6 21 3 18/21 0.857 0.076
7 17 1 16/17 0.807 0.087
10 15 1 14/15 0.753 0.096
13 12 1 11/12 0.690 0.107
16 11 1 10/11 0.627 0.114
22 7 1 6/7 0.538 0.128
23 6 1 5/6 0.448 0.135

At week 6 all 21 are at risk and 3 relapse, so the first factor is $18/21 = 0.857$. The patient censored at 6 is counted at risk at week 6 and then leaves, so 17 remain at week 7, where one relapses: $\hat S(7) = (18/21)(16/17) = 96/119 = 0.807$. The patient censored at 9 leaves before week 10, and so on. At week 23 the product is exactly $\hat S(23) = 160/357$, and the curve stays there until the last observation, a remission still continuing at 35 weeks.

Example (the censored patients are not counted as surviving forever). A tempting shortcut divides the number still in remission at $t$ by 21. At week 13, six patients have relapsed, and $(21 - 6)/21$ is right only if the patients censored at 6, 9, 10 and 11 weeks are still in remission at week 13. Nobody knows that. The opposite shortcut drops them from the denominator altogether, as if they had never been enrolled, which throws away the weeks during which they were seen to be in remission. The product does neither: each censored patient counts in every factor up to the censoring time and in none after it.

The estimator as a maximum likelihood estimate

Why multiply estimated conditional probabilities, rather than estimate $S$ some other way? The answer is that the product maximizes the likelihood over every possible distribution of $T$, with no parametric form assumed.

Under independent and noninformative censoring, the likelihood of a distribution for $T$ is the product of $f(y_i)$ over the events and $S(y_i)$ over the censored observations, up to constant censoring factors. Censoring, Survival Functions and Hazards derives it (section "The likelihood of censored data"). For a distribution with no density the event factor becomes a probability, $P(T = y_i)$, and that is the form used here. A continuous distribution gives every observed event probability zero, so the maximum must come from distributions with atoms.

Theorem 1 (the nonparametric maximum likelihood estimate). Let the data contain at least one event. For a probability distribution $P$ of $T$ on $[0, \infty]$ (mass at $\infty$ is allowed), define

$$L(P) = \prod_{i:\, \delta_i = 1} P(T = y_i) \prod_{i:\, \delta_i = 0} P(T > y_i).$$

Then $L(P) \le \prod_{j=1}^{k} \hat h_j^{\,d_j}(1 - \hat h_j)^{n_j - d_j}$ with $\hat h_j = d_j/n_j$ (and $0^0 = 1$). Equality holds if and only if $P(T > t) = \hat S(t)$ for every $t \le y_{\max}$, the largest observation. Such distributions exist: put mass $\hat S(t_{(j-1)}) - \hat S(t_{(j)})$ at each $t_{(j)}$ (with $\hat S(t_{(0)}) = 1$) and the remaining mass $\hat S(t_{(k)})$ anywhere strictly beyond $y_{\max}$.

Proof. Take any $P$ with $L(P) > 0$, and write $p_j = P(T = t_{(j)})$, $q_j = P(T \ge t_{(j)})$ and $h_j = p_j/q_j$, the hazard of $P$ at $t_{(j)}$. Since $L(P) > 0$, each $p_j > 0$, so $0 < h_j \le 1$.

Step 1: a bound on survival. The event $\{T \ge t_{(j+1)}\}$ is contained in $\{T > t_{(j)}\}$, so

$$q_{j+1} \le P(T > t_{(j)}) = q_j - p_j = q_j(1 - h_j).$$

With $q_1 \le 1$, induction gives $q_j \le \prod_{l < j}(1 - h_l)$ and $P(T > t_{(j)}) \le \prod_{l \le j}(1 - h_l)$. For a censoring time $c$ with $t_{(j)} \le c < t_{(j+1)}$, $P(T > c) \le P(T > t_{(j)}) \le \prod_{l \le j}(1 - h_l)$; for $c < t_{(1)}$, $P(T > c) \le 1$, the empty product.

Step 2: collect the factors. An event at $t_{(j)}$ contributes $p_j = h_j q_j \le h_j\prod_{l<j}(1 - h_l)$. A censoring at $c$ with $t_{(j)} \le c$ contributes at most $\prod_{l \le j}(1 - h_l)$. Multiply over all observations. The factor $h_j$ appears $d_j$ times. The factor $(1 - h_l)$ appears once for each event at a time after $t_{(l)}$ and once for each censoring at a time $c \ge t_{(l)}$. That is once for each person at risk at $t_{(l)}$ who does not die there: $n_l - d_l$ times. Hence

$$L(P) \le \Lambda(h_1, \ldots, h_k) = \prod_{j=1}^{k} h_j^{\,d_j}(1 - h_j)^{n_j - d_j}.$$

Step 3: maximize each factor. On $[0, 1]$ the function $h^{d}(1 - h)^{n - d}$ with $1 \le d \le n$ has its unique maximum at $h = d/n$. For $d < n$ the derivative of its logarithm, $d/h - (n - d)/(1 - h)$, is positive below $d/n$ and negative above, and for $d = n$ the function is $h^n$, largest at $h = 1 = d/n$. So $L(P) \le \Lambda(\hat h_1, \ldots, \hat h_k)$.

Step 4: equality. $L(P)$ depends on $P$ only through $P(T > c)$ at the censoring times $c \le y_{\max}$ and through $P(T = t_{(j)}) = \lim_{s \uparrow t_{(j)}} P(T > s) - P(T > t_{(j)})$. If $P(T > t) = \hat S(t)$ for every $t \le y_{\max}$, these are $\hat S(c)$ and $\hat S(t_{(j-1)}) - \hat S(t_{(j)})$, so $L(P)$ is the same for every such $P$. For the distribution described in the statement, the hazard at $t_{(j)}$ is $[\hat S(t_{(j-1)}) - \hat S(t_{(j)})]/\hat S(t_{(j-1)}) = \hat h_j$. It has no mass strictly between event times, or between an event time and a later censoring time up to $y_{\max}$. So every inequality of Step 1 that was used is an equality, and $L(P) = \Lambda(\hat h)$; hence the same holds for every $P$ with $P(T > t) = \hat S(t)$ on $[0, y_{\max}]$. Conversely, suppose $L(P) = \Lambda(\hat h)$. Step 3 is strict unless $h_j = \hat h_j$ for every $j$. Each $q_j$ enters $L$ through $d_j \ge 1$ event factors, so equality also forces $q_j = \prod_{l<j}(1 - \hat h_l) = \hat S(t_{(j-1)})$, and each censoring factor forces $P(T > c) = \hat S(c)$ at every censoring time $c$. For $t_{(j)} \le t < t_{(j+1)}$ we then have $\hat S(t_{(j)}) = q_{j+1} \le P(T > t) \le P(T > t_{(j)}) = q_j(1 - \hat h_j) = \hat S(t_{(j)})$. For $t < t_{(1)}$, $1 = q_1 \le P(T > t) \le 1$. At $t = t_{(k)}$, $P(T > t_{(k)}) = q_k(1 - \hat h_k) = \hat S(t_{(k)})$ directly. For $t_{(k)} < t \le y_{\max}$, if $y_{\max}$ is a censoring time then $\hat S(t_{(k)}) = P(T > y_{\max}) \le P(T > t) \le P(T > t_{(k)}) = \hat S(t_{(k)})$; if $y_{\max} = t_{(k)}$ there is no such $t$. So $P(T > t) = \hat S(t)$ on $[0, y_{\max}]$. $\square$

Three remarks complete the picture.

  • The maximum is a product of binomial likelihoods. $\Lambda$ is the likelihood of $k$ independent binomial experiments, $d_j$ deaths among $n_j$ at risk, each with its own probability $h_j$. That is why the hazard estimates are $d_j/n_j$, and it is the structure that the variance calculations below use.
  • The maximizer is not unique beyond $y_{\max}$. When the last observation is censored, any way of placing the remaining mass $\hat S(t_{(k)})$ beyond it gives the same likelihood. The data identify $S$ only up to the end of observation.
  • A continuous distribution can approximate $\hat S$ as closely as we like, but its likelihood is 0. A density gives each event factor the value 0, so $L = 0$. Smooth estimates of $S$ need a model, which is the subject of Parametric Survival Models.

For the 6-MP group the maximized log-likelihood is $\sum_j [d_j\ln(d_j/n_j) + (n_j - d_j)\ln(1 - d_j/n_j)] = -28.457$. The script draws 20,000 random discrete distributions on the observed times and a point beyond them; none comes higher, and a numerical maximization over the seven hazards returns $d_j/n_j$.

No censoring: the empirical survival function

Kaplan and Meier's abstract also notes that "when no losses occur at ages less than $t$", the estimate "reduces to the usual binomial estimate, namely, the observed proportion of survivors". The proof is one line of telescoping.

Theorem 2 (no censoring before $t$). If no observation is censored before $t$, then $\hat S(t)$ equals the share of the $n$ people known to survive past $t$: those with $Y_i > t$, together with those censored at exactly $t$, who survived $t$ by the unit's convention. If no observation is censored at or before $t$, this is the share with $Y_i > t$. If also $\hat S(t) > 0$, then Greenwood's variance estimate, $\hat S(t)^2\sum_{t_{(j)} \le t} d_j/[n_j(n_j - d_j)]$, equals $\hat S(t)[1 - \hat S(t)]/n$.

Proof. With no censoring before $t$, everyone at risk at $t_{(j)}$ who does not die there is at risk at $t_{(j+1)}$, for every $t_{(j+1)} \le t$. So $n_{j+1} = n_j - d_j$, and with $n_1 = n$ (nobody has left before the first event),

$$\hat S(t) = \prod_{j \le m}\frac{n_j - d_j}{n_j} = \frac{n_2}{n_1}\cdot\frac{n_3}{n_2}\cdots\frac{n_m - d_m}{n_m} = \frac{n_m - d_m}{n},$$

where $t_{(m)}$ is the last event time at or before $t$. The numerator $n_m - d_m$ counts those at risk at $t_{(m)}$ who did not die there. Since nobody dies in $(t_{(m)}, t]$ and nobody was censored before $t$, they are the people with $Y_i > t$ together with those censored at exactly $t$. All of them are known to survive past $t$. (If no event has occurred by $t$, then $\hat S(t) = 1$, and everyone has $Y_i \ge t$ and is known to survive past $t$.) For the variance, $d_j/[n_j(n_j - d_j)] = 1/(n_j - d_j) - 1/n_j = 1/n_{j+1} - 1/n_j$ for $j < m$, and the last term is $1/(n_m - d_m) - 1/n_m$. The sum telescopes to $1/(n_m - d_m) - 1/n = 1/(n\hat S) - 1/n$. Multiplying by $\hat S^2$ gives $\hat S(1 - \hat S)/n$. $\square$

The placebo group of the trial has no censoring, and its estimate is the share of patients still in remission: $\hat S(8) = 8/21 = 0.381$. The script checks the identity and the variance at every event time. In the NHANES 1999 to 2000 cohort below, nobody is censored before 226 months, so every estimate before then is simply a share of survivors.

The Nelson–Aalen estimator

The cumulative hazard $H(t)$ is a second way to describe a lifetime. For a discrete distribution it is the sum of the hazards, $H(t) = \sum_{t_{(j)} \le t} h_j$, and for a continuous one $H(t) = \int_0^t h(u)\,du$ with $S(t) = e^{-H(t)}$ (Censoring, Survival Functions and Hazards, Theorem 1). Replacing each hazard by its estimate gives the Nelson–Aalen estimator

$$\hat H(t) = \sum_{j:\, t_{(j)} \le t}\frac{d_j}{n_j}.$$

It carries two names. Nelson (1972) developed the theory of hazard plotting, a graphical method for "multiply censored life data" that is "based on the hazard function of a distribution" (his abstract). Aalen (1978) defined an estimator of the integrated intensity of a counting process that "generalizes the empirical cumulative hazard rate from survival analysis". He gave consistency and weak convergence results for it (his abstract).

Two estimates of $S$ are now available: the Kaplan–Meier product and $\exp(-\hat H)$. They estimate the same function when $T$ is continuous, since then $S = e^{-H}$. They are not equal.

Theorem 3 (Kaplan–Meier lies below the exponential of Nelson–Aalen). For every $t$, $\hat S(t) \le \exp(-\hat H(t))$, with equality if and only if no event has occurred by $t$.

Proof. This is the sample version of the inequality $S \le \exp(-\sum h_j)$ in Theorem 2 of Censoring, Survival Functions and Hazards. For $0 \le x \le 1$, $1 - x \le e^{-x}$, with equality only at $x = 0$: the function $e^{-x} - (1 - x)$ is 0 at $x = 0$ and has derivative $1 - e^{-x} > 0$ for $x > 0$. Apply this to each factor with $x = d_j/n_j > 0$ and multiply the nonnegative factors: $\prod_j(1 - d_j/n_j) \le \prod_j e^{-d_j/n_j} = e^{-\hat H(t)}$. If at least one event has occurred by $t$, that factor is strictly smaller, and the other factors of the left side are at most the corresponding factors of the right side. So the inequality is strict whenever the left side is positive; when the left side is 0, the right side is still positive. With no events both sides are 1. $\square$

The gap is small when each $d_j/n_j$ is small, since $\ln(1 - x) = -x - x^2/2 - \cdots$, so $\ln\hat S(t) = -\hat H(t) - \sum_j (d_j/n_j)^2/2 - \cdots$. It is large where few are at risk. For the 6-MP group at 23 weeks, $\hat H = 0.7521$, $e^{-\hat H} = 0.4714$ and $\hat S = 0.4482$.

How variable is $\hat H$? In continuous time the answer comes from the theory of counting processes and martingales, which we cite below. In discrete time it is exact and elementary, and the argument is worth seeing because the same structure carries every variance in this unit and the next article.

Suppose the possible times are a finite grid $\tau_1 < \cdots < \tau_m$ (months, as in NHANES), and $T$ has hazards $h_1, \ldots, h_m$ on it. Censoring is independent and happens after the events of its time. Let $N_l$ be the number at risk at $\tau_l$ and $D_l$ the number of deaths there. Given everything observed before $\tau_l$, each of the $N_l$ people at risk dies at $\tau_l$ with probability $h_l$. A person at risk has $T \ge \tau_l$ and $C \ge \tau_l$, and since $C$ is independent of $T$, $P(T = \tau_l \mid T \ge \tau_l, C \ge \tau_l) = h_l$. People are independent, so given the past, $D_l$ is binomial with $N_l$ trials and probability $h_l$.

Theorem 4 (the Nelson–Aalen estimator in discrete time). In this model let $\hat H(\tau_l) = \sum_{l' \le l} (D_{l'}/N_{l'})\,\mathbf{1}\{N_{l'} > 0\}$ and $H^*(\tau_l) = \sum_{l' \le l} h_{l'}\,\mathbf{1}\{N_{l'} > 0\}$, the cumulative hazard over the times at which someone was at risk. Then

$$E\big[\hat H(\tau_l) - H^*(\tau_l)\big] = 0, \qquad \operatorname{Var}\big[\hat H(\tau_l) - H^*(\tau_l)\big] = \sum_{l' \le l} E\Big[\frac{h_{l'}(1 - h_{l'})}{N_{l'}}\mathbf{1}\{N_{l'} > 0\}\Big].$$

Proof. Let $X_l = (D_l/N_l - h_l)\mathbf{1}\{N_l > 0\}$, so that the difference is $X_1 + \cdots + X_l$. Write $\mathcal{P}_l$ for everything observed before $\tau_l$; it determines $N_l$. By the binomial distribution, $E[X_l \mid \mathcal{P}_l] = 0$ and $E[X_l^2 \mid \mathcal{P}_l] = h_l(1 - h_l)/N_l$ when $N_l > 0$ (and 0 otherwise). Taking expectations, $E[X_l] = 0$, which proves the first claim. For $l < l'$, $X_l$ is a function of what is observed before $\tau_{l'}$, so by the averaging property of conditional expectation (Conditional Expectation), $E[X_lX_{l'}] = E\big[X_l\,E[X_{l'} \mid \mathcal{P}_{l'}]\big] = 0$. The terms are uncorrelated, so the variance of their sum is the sum of $E[X_l^2] = E\big[E[X_l^2 \mid \mathcal{P}_l]\big]$. $\square$

The theorem is about the error $\hat H - H^*$, where $H^*$ is itself random. $\hat H(\tau_l)$ is unbiased for the cumulative hazard $H(\tau_l)$ only when the risk set cannot empty before $\tau_l$; otherwise $E[\hat H(\tau_l)] = E[H^*(\tau_l)]$ falls short of it.

The partial sums $X_1 + \cdots + X_l$ form a martingale (Random Walks and Martingales): each increment has conditional mean zero given the past. Their increments are not independent, because the number at risk depends on earlier deaths, but they are uncorrelated, and that is all a variance needs.

Two variance estimates follow by replacing $h_l$ with $D_l/N_l$. The binomial form $\sum_l D_l(N_l - D_l)/N_l^3$ has, given the past, expectation $(N_l - 1)h_l(1 - h_l)/N_l^2$ per term, a slight underestimate (the unbiased version divides by $N_l^2(N_l - 1)$). The form $\sum_l D_l/N_l^2$, which is what the continuous-time theory gives, has expectation $h_l/N_l$ per term and overstates the discrete-time variance by $h_l^2/N_l$. It is the right one when deaths are rare in each interval, as they are for continuous time. For the 6-MP group at 23 weeks the two are 0.06776 and 0.07810, a standard error of 0.279 by the second.

Greenwood's formula by the delta method

For the Kaplan–Meier estimate itself the variance has no exact formula. The standard one, which Breslow and Crowley (1974) in their abstract call "Greenwood's variance formula", comes from linearizing. Here is the plan: take logarithms to turn the product into a sum, linearize each term, and use the uncorrelated increments of Theorem 4.

In the discrete-time model, $\ln\hat S(\tau_l) = \sum_{l' \le l}\ln(1 - \hat h_{l'})$, with $\hat h = D/N$. The function $g(x) = \ln(1 - x)$ has $g'(x) = -1/(1 - x)$, so to first order

$$\ln(1 - \hat h_{l'}) - \ln(1 - h_{l'}) \approx -\frac{\hat h_{l'} - h_{l'}}{1 - h_{l'}} = -\frac{X_{l'}}{1 - h_{l'}}.$$

The right sides are the increments $X_{l'}$ of Theorem 4 multiplied by constants, so they are uncorrelated, and by Theorem 4 their variances add:

$$\operatorname{Var}\big(\ln\hat S(\tau_l)\big) \approx \sum_{l' \le l}\frac{1}{(1 - h_{l'})^2}\,E\Big[\frac{h_{l'}(1 - h_{l'})}{N_{l'}}\Big] = \sum_{l' \le l} E\Big[\frac{h_{l'}}{N_{l'}(1 - h_{l'})}\Big].$$

Replacing $h_{l'}$ by $d_{l'}/n_{l'}$ and the expectation by the observed value gives Greenwood's estimate of the variance of the logarithm,

$$\hat\sigma^2(t) = \sum_{j:\, t_{(j)} \le t}\frac{d_j}{n_j(n_j - d_j)},$$

and a second application of the delta method, with $g(x) = e^x$ and $g' = e^x$, gives Greenwood's formula

$$\widehat{\operatorname{Var}}\big(\hat S(t)\big) = \hat S(t)^2\sum_{j:\, t_{(j)} \le t}\frac{d_j}{n_j(n_j - d_j)}.$$

What is exact and what is heuristic. The uncorrelatedness of the increments across time is exact (Theorem 4), so no assumption of independence between the factors is needed. The heuristic steps are two. The first is the linearization: the remainder of $\ln(1 - \hat h)$ beyond the linear term is ignored. The Delta Method proves that such a remainder is negligible only in the limit, for a fixed function of an estimate whose error shrinks. Here the number of terms and the numbers at risk change together, and no limit theorem is proved on this page. The second is the replacement of $E[1/N]$ and $h$ by their observed values. Breslow and Crowley's (1974) abstract states that Greenwood's formula is "nearly correct" for the actuarial life table, and that the product-limit estimate is asymptotically normal for continuous survival distributions. We did not check in the paper whether Greenwood's formula is shown there to estimate the product-limit variance consistently, so the limit results are cited, and the formula's accuracy for Kaplan–Meier is judged here by the simulation in "Which interval to use". Greenwood's sum is infinite when $d_j = n_j$, where $\hat S$ reaches 0 and no variance is reported.

What the formula says about censoring. When $n$ is large, $n_j$ is close to $n\,P(Y \ge t_{(j)}) = n\,S(t_{(j)}^-)G(t_{(j)}^-)$, and in continuous time $d_j/n_j$ summed over a short interval is close to $h(u)\,du$. So, heuristically,

$$\hat\sigma^2(t) \approx \frac{1}{n}\int_0^t\frac{h(u)}{S(u)\,G(u)}\,du.$$

With no censoring, $G = 1$, and $\int_0^t h/S = \int_0^t f/S^2 = 1/S(t) - 1$, which reproduces the binomial variance of Theorem 2. Censoring enters only through $1/G$: a stretch of time in which most people have been censored contributes a large share of the variance, however few deaths occur there.

Three confidence intervals

The plain interval $\hat S(t) \pm z_{0.975}\,\widehat{\operatorname{se}}$ treats $\hat S(t)$ as approximately normal on its own scale. It can extend past 0 or 1, and it is symmetric even when $\hat S$ is near a boundary, where its sampling distribution is skewed. Without censoring it is the Wald interval for a binomial proportion, whose poor coverage near 0 and 1 Confidence Intervals for a Proportion documents. Two transformed intervals apply the normal approximation on a scale where it is better and transform back.

  • Log. On the scale of $\ln\hat S$ the variance estimate is $\hat\sigma^2$ itself. The interval $\ln\hat S \pm z\hat\sigma$ transforms to $\hat S\,e^{\pm z\hat\sigma}$. It stays above 0 but can pass 1, where it is cut off.
  • Log-log. Take $g(x) = \ln(-\ln x)$, with $g'(x) = 1/(x\ln x)$. By the delta method $\ln(-\ln\hat S)$ has variance about $\hat S^2\hat\sigma^2/(\hat S\ln\hat S)^2 = \hat\sigma^2/(\ln\hat S)^2$. The interval $\ln(-\ln\hat S) \pm z\hat\sigma/|\ln\hat S|$ transforms back to $$\hat S(t)^{\exp(z\hat\sigma/|\ln\hat S|)} \le S(t) \le \hat S(t)^{\exp(-z\hat\sigma/|\ln\hat S|)}.$$ Both exponents are positive, so both ends lie in $(0, 1)$ whenever $0 < \hat S < 1$. The scale $\ln(-\ln S) = \ln H$ is that of the cumulative hazard for a continuous lifetime.

On the 6-MP group, with 95% intervals:

at 13 weeks, $\hat S = 0.690$ at 23 weeks, $\hat S = 0.448$
Plain 0.481 to 0.900 0.184 to 0.712
Log 0.510 to 0.935 0.249 to 0.807
Log-log 0.432 to 0.849 0.188 to 0.680

The plain interval is symmetric about $\hat S$; the log interval leans upward; the log-log interval leans downward, away from 1. At 6 weeks the plain upper end, before cutting at 1, is 1.007.

Example (an interval that cannot be right). At 6 weeks the plain interval claims that the remission probability may be as high as 1.007. No probability is, and cutting the interval at 1 hides the symptom without curing it. Near the boundary the estimator's distribution is lopsided, and a symmetric interval misplaces its two ends. The transformed intervals put the asymmetry in the right direction by construction.

Which interval to use

Which interval covers the true value 95% of the time is a question for simulation. The script draws lifetimes from the exponential distribution with rate 1 and censoring times, independently, from the exponential with rate 3/7, so that 30% of observations are censored. It computes the three 95% intervals at the times where $S$ is 0.9, 0.5 and 0.1, for samples of 20, 50 and 200. There are 30 runs (seeds 81,000,000 to 81,000,029) of 2,000 data sets each. A data set in which no interval can be formed (no event yet, so $\hat S = 1$; or $\hat S = 0$) counts as a miss. Medians over the 30 runs, with interquartile ranges:

$n$ true $S$ plain log log-log
20 0.9 0.866 (0.861 to 0.872) 0.870 (0.864 to 0.875) 0.834 (0.826 to 0.838)
20 0.5 0.922 (0.920 to 0.926) 0.934 (0.932 to 0.936) 0.954 (0.951 to 0.957)
20 0.1 0.655 (0.648 to 0.664) 0.590 (0.584 to 0.595) 0.639 (0.633 to 0.648)
50 0.9 0.880 (0.875 to 0.882) 0.878 (0.875 to 0.882) 0.961 (0.957 to 0.962)
50 0.5 0.938 (0.935 to 0.942) 0.942 (0.939 to 0.945) 0.949 (0.947 to 0.954)
50 0.1 0.865 (0.858 to 0.869) 0.840 (0.835 to 0.847) 0.869 (0.863 to 0.873)
200 0.9 0.944 (0.940 to 0.947) 0.939 (0.937 to 0.943) 0.948 (0.946 to 0.951)
200 0.5 0.947 (0.944 to 0.950) 0.948 (0.945 to 0.951) 0.949 (0.947 to 0.953)
200 0.1 0.933 (0.928 to 0.935) 0.957 (0.953 to 0.961) 0.953 (0.951 to 0.957)

Four observations of this experiment:

  • With 200 observations all three are close to 95% in the middle of the curve. In the tail the plain interval falls to 0.933 while the two transformed intervals stay near or above 0.95.
  • With 50 observations and $S = 0.9$, the plain and log intervals cover 0.880 and 0.878 and the log-log interval 0.961. The plain and log intervals miss almost entirely on one side: in 0.113 and 0.118 of the data sets the whole interval lies above the true value, against 0.008 and 0.004 below it. They are too short on the low side. The log-log interval misses below in 0.034; its only misses above, 0.006, are the data sets with no event yet, where $\hat S = 1$ and no interval can be formed. At $S = 0.5$ all three are near 95%. At $S = 0.1$ all three cover about 0.84 to 0.87, mainly because in a median of 0.103 of the data sets (0.098 to 0.108) no interval can be formed.
  • With 20 observations the tails are not estimable in any useful sense. At $S = 0.9$ a median of 0.129 of the data sets (0.123 to 0.134) have no event before the target time, so $\hat S = 1$ and every interval misses. At $S = 0.1$ the expected number still at risk is $20 \times 0.1 \times e^{-(3/7)\ln 10} = 0.75$. In a median of 0.329 of the data sets (interquartile range 0.321 to 0.337) no interval can be formed at all. The coverage figures there measure how often the data run out, not the quality of an interval.
  • Greenwood's variance tracks the Monte Carlo variance of $\hat S(t)$ when the risk set is not thin. Both are computed over the same data sets, those in which the Greenwood sum is finite and $\hat S > 0$. With 200 observations the ratio of the average Greenwood estimate to the simulated variance is 0.97 (0.97 to 1.00), 0.99 (0.97 to 1.00) and 0.99 (0.97 to 1.00) at $S$ = 0.9, 0.5 and 0.1. In the tail at small samples it is not: at $S = 0.1$ the ratio is 1.25 (1.22 to 1.27) for $n = 50$ and 1.72 (1.66 to 1.76) for $n = 20$. Part of this is the restriction: leaving out the data sets in which $\hat S$ reached 0 also lowers the simulated variance. Over all data sets the ratios are 1.11 and 0.97, but there Greenwood's estimate is infinite in a third and a tenth of them. Either way, Greenwood's variance is not a reliable guide where the risk set is this thin, and the heuristic steps named above are far from their limit.

So the log-log interval is a sound default: near 95% with 200 observations across the curve, and with 50 everywhere except the far tail, where no interval does well. That is the conclusion of this experiment for exponential lifetimes and exponential censoring; other shapes and censoring patterns would need their own runs.

The median and its interval

A survival curve is often summarized by its median, $\hat m = \min\{t : \hat S(t) \le 1/2\}$, the first time the estimate reaches one half. For the 6-MP group that is 23 weeks; for placebo, 8 weeks. A median exists only if the curve gets that low: among NHANES adults without diabetes it does not within twenty years.

Brookmeyer and Crowley (1982) obtained an interval for the median "by inverting a generalization of the sign test for censored data" (their abstract). In the form used here, the construction tests $H_0\!: S(t) = 1/2$ at each event time with the statistic $z(t) = [\hat S(t) - 1/2]/\widehat{\operatorname{se}}(t)$ and Greenwood's standard error. It collects the times at which the test does not reject at level 0.05. The interval runs from the first accepted event time to the first event time after the last accepted one, because the estimate keeps the accepted value until then.

For the 6-MP group the statistics at the event times are 4.68, 3.53, 2.63, 1.78, 1.12, 0.29 and $-0.39$. The test rejects at weeks 6, 7 and 10 ($z = 2.63$ at week 10) and accepts from week 13 ($z = 1.78$) onward. The last event time is accepted, and the curve never again falls, so the interval runs from 13 weeks to beyond the end of follow-up. The data give a lower limit and no upper one. For placebo the median is 8 weeks with interval 4 to 11 weeks.

Proposition 1 (the median's interval and the pointwise interval). Suppose the set of accepted event times is a run of consecutive event times. Then the Brookmeyer–Crowley interval contains a time $m$ if and only if the plain pointwise interval for $S(m)$ contains $1/2$.

Proof. Let $t_{(a)}$ and $t_{(b)}$ be the first and last accepted event times, so that the interval is $[t_{(a)}, t_{(b+1)})$, with $t_{(b+1)} = \infty$ if $t_{(b)}$ is the last event time. The plain interval at $m$ uses $\hat S(m) = \hat S(t_{(c)})$, where $t_{(c)}$ is the last event time at or before $m$. It contains $1/2$ exactly when $(\hat S(t_{(c)}) - 1/2)^2 \le z^2\widehat{\operatorname{Var}}(\hat S(t_{(c)}))$, that is, when $t_{(c)}$ is accepted. Since the accepted times are consecutive, that happens exactly when $a \le c \le b$, which is the same as $t_{(a)} \le m < t_{(b+1)}$. If $m$ precedes every event time, $\hat S(m) = 1$ with variance estimate 0, the plain interval is $\{1\}$, and $m < t_{(a)}$; both sides fail. $\square$

So when the true median is $m$, the median's interval covers it exactly when the plain interval at $m$ covers $1/2 = S(m)$. Its coverage is the plain interval's coverage at $S = 0.5$. In the simulation above the two coverages were identical in each of the 30 runs. For 20, 50 and 200 observations they were 0.922 (0.920 to 0.926), 0.938 (0.935 to 0.942) and 0.947 (0.944 to 0.950). Using the log-log interval in the same construction gives a median interval with the log-log interval's coverage at one half, which is how many programs build it.

Why the obvious estimate is wrong

Back to the NHANES 2017 to 2018 adults. The course pages use 5,247 adults with a blood pressure reading, and 5,219 of them were eligible for linkage to the National Death Index. The National Center for Health Statistics (NCHS) carried the linkage through 31 December 2019 (NCHS, 2022). Follow-up is counted in whole months from the examination. Because examinations ran across two years, the survivors' follow-up ranges from 11 months to 37 months, and 116 deaths were seen.

The share who died is $116/5{,}219 = 0.0222$, and the share alive 0.9778. The Kaplan–Meier estimates are

months since examination 12 24 36
$\hat S$ 0.9858 0.9791 0.9695

so the estimated probability of dying within 36 months is 0.0305, more than a third higher than the naive 0.0222. The naive figure treats everyone as followed for 37 months. In fact only 2,629 adults were followed for 24 months or more, and only 83 were still at risk at 36 months. The 14 deaths after the second year were seen among these few, and the product weights them accordingly. Theorem 2 says when the two estimates must agree: when nobody has been censored, which is far from the case here. Without assuming independent censoring, the data confine $S$ only to the band of Theorem 7 in Censoring, Survival Functions and Hazards, which at 24 months runs from 0.5037 to 0.9805.

The National Center for Health Statistics perturbs the public-use files: "Synthetic data were substituted for follow-up time or underlying cause of death for select records. Information regarding vital status was not perturbed" (NCHS, 2022). So an individual follow-up time may be synthetic, while whether a person died is not. Estimates from many people are affected little; no single person's time should be read as fact.

Twenty years of NHANES follow-up

The NHANES 1999 to 2000 adults have been followed for much longer. Of the 4,802 adults with a blood pressure reading who were eligible for linkage, the unit uses 4,114. The smoking questions were asked from age 20, so the 517 aged 18 or 19 are left out, and so are the 112 at age 85, the survey's top code; that leaves 4,173 aged 20 to 84. Of these, 52 did not answer yes or no to whether a doctor had ever told them they had diabetes ("borderline", refused, did not know or no answer) and 9 have no smoking status, 2 of them in both groups, which leaves 4,114. Of the 4,114, 1,240 died by the end of 2019. Every survivor was followed for at least 226 months and at most 249 months; the last death seen was at 247 months. The 416 with diagnosed diabetes are older on average than the 3,698 without, 62.8 years against 47.2, and that difference alone predicts much of what follows.

diagnosed diabetes no diagnosis
adults 416 3,698
deaths by end of 2019 273 967
$\hat S$ at 5 years (60 months) 0.820 0.955
$\hat S$ at 10 years 0.651 0.883
$\hat S$ at 15 years 0.490 0.814
$\hat S$ at 20 years 0.341 0.737
median 178 months not reached

Since nobody is censored before 226 months, Theorem 2 applies to every row except the 20-year one: the 5-, 10- and 15-year entries and the median are shares of the group still alive, and the script confirms it at 5, 10, 15 and 18.75 years. The 20-year entry uses the product over the last 14 months, after censoring has begun. It is not a share: for diagnosed diabetes it is 0.341, below the share not seen to die by 240 months, $1 - 272/416 = 0.346$.

The median of 178 months depends on a convention. By month 178, 208 of the 416 with diabetes had died, so $\hat S = 208/416 = 1/2$ exactly from month 178 until the next death at month 179. The definition used here, the first time at which $\hat S \le 1/2$, gives 178; programs that report the middle of a flat stretch at exactly one half would give 178.5. The censoring of this cohort is purely administrative and comes only at the end, so for these data the Kaplan–Meier machinery is needed only in the last two years. The 2017 to 2018 cohort above is the case where it does all the work.

At 20 years the three 95% intervals nearly coincide, because the groups are large:

plain log log-log
diagnosed diabetes 0.294 to 0.387 0.297 to 0.390 0.295 to 0.387
no diagnosis 0.723 to 0.752 0.723 to 0.752 0.722 to 0.751

The median for diagnosed diabetes is 178 months, with Brookmeyer–Crowley interval 161 to 196 months from Greenwood's variance (160 to 196 with the log-log interval). The Nelson–Aalen estimates at 240 months are 1.0727 and 0.3047. Their exponentials, 0.3421 and 0.7374, lie just above the Kaplan–Meier estimates 0.3405 and 0.7372, as Theorem 3 requires. The gap is small because each month's deaths are a small share of those at risk.

Kaplan–Meier curves with pointwise 95% log-log intervals. Left: the 6-MP trial; notice that the placebo curve, which has no censoring, falls to 0, while the 6-MP curve stops at 0.448 with its last patients still in remission. Right: NHANES 1999 to 2000 adults by diagnosed diabetes over 249 months; notice how narrow the band is for the 3,698 adults without diabetes, and that both curves end flat after the last death.
Kaplan–Meier curves with pointwise 95% log-log intervals. Left: the 6-MP trial; notice that the placebo curve, which has no censoring, falls to 0, while the 6-MP curve stops at 0.448 with its last patients still in remission. Right: NHANES 1999 to 2000 adults by diagnosed diabetes over 249 months; notice how narrow the band is for the 3,698 adults without diabetes, and that both curves end flat after the last death.

These are crude curves. People with diabetes were about 16 years older on average. Age alone would separate the curves. The Log-Rank Test compares the groups within age bands, and The Cox Proportional Hazards Model adjusts for age as a continuous variable. As on the course pages, the NHANES sampling weights are not used, so the figures describe these adults rather than the United States population.

The tail of the curve

Every curve above ends flat. For diagnosed diabetes the last death is at 242 months, with 50 adults at risk, and the estimate stays at 0.334 to the end of follow-up. Without diabetes the last death is at 247 months, with 240 at risk, and the estimate ends at 0.726. Beyond the largest observation the estimator is not defined, because Theorem 1 leaves the remaining mass free.

Three consequences matter in practice.

  • The mean survival time is not estimable when the last observation is censored, since $E[T] = \int_0^\infty S(t)\,dt$ needs $S$ beyond the data. Two conventions are in use. One treats the largest observation as an event, setting $\hat S$ to 0 there, which biases the mean downward. The other reports the restricted mean $\int_0^\tau \hat S(t)\,dt$ up to a stated time $\tau$ within follow-up. The second estimates a well-defined quantity; the first does not.
  • The right end of the curve rests on few people. Greenwood's formula already shows this through $n_j$ in the denominator. The coverage experiment shows what happens when the expected number at risk falls below one. A curve plotted to its last step invites the eye to trust its least reliable part.
  • No method can estimate beyond the censoring. If no one is followed past some time $\tau$, the data carry no information about $S(t)$ for $t > \tau$. Censoring, Survival Functions and Hazards treats this limit of identifiability (Theorem 5, section "What the observed data identify").

When censoring is informative

Everything so far assumed that censoring is independent of the lifetime. What does the estimator estimate when it is not? Each factor $d_j/n_j$ estimates the probability of dying at $t_{(j)}$ among those still observed. If leaving the study depends on frailty, those still observed are not representative of everyone alive.

To see the size of the effect, the script makes half the population robust (hazard 0.5) and half frail (hazard 2). The true survival function is $S(t) = \tfrac12 e^{-0.5t} + \tfrac12 e^{-2t}$: $S(0.5) = 0.573$ and $S(1.5) = 0.261$. Censoring is exponential, with a rate that depends on the type in three ways:

  • independent: rate 0.5 for both types (median share censored 0.350);
  • the frail leave: rate 0.9 for the frail, 0.1 for the robust (median share censored 0.239), as when the sickest participants stop attending;
  • the robust leave: rate 0.1 for the frail, 0.9 for the robust (median share censored 0.345), as when healthy participants move away.

What the estimator converges to. Here is the heuristic. In a large sample, $d_j/n_j$ is close to the crude hazard $h^\#(t)\,dt$, the probability of an observed death in $[t, t + dt)$ among those with $Y \ge t$. It is the hazard $h_1^*$ of Theorem 6 in Censoring, Survival Functions and Hazards. With two types of shares $\pi_1, \pi_2$, hazards $a_1, a_2$ and censoring rates $c_1, c_2$,

$$h^\#(t) = \frac{\sum_r \pi_r a_r e^{-(a_r + c_r)t}}{\sum_r \pi_r e^{-(a_r + c_r)t}},$$

and the estimator tends to $\exp\big(-\int_0^t h^\#(u)\,du\big)$. When $c_1 = c_2$ the factor $e^{-ct}$ cancels and $h^\#$ is the hazard of $T$, so the limit is $S(t)$; that is the content of independent censoring. Otherwise the limit is another function.

With 2,000 data sets of 200 people in each of 30 runs (seeds 82,000,000 to 82,000,029), the median bias of $\hat S$ was:

censoring limit at 0.5 bias at 0.5 limit at 1.5 bias at 1.5
independent 0.573 0.000 (0.000 to 0.000) 0.261 0.000 (−0.001 to 0.000)
the frail leave 0.593 0.019 (0.019 to 0.020) 0.307 0.046 (0.045 to 0.046)
the robust leave 0.553 −0.020 (−0.021 to −0.020) 0.203 −0.058 (−0.058 to −0.057)

When the frail leave, the risk sets are left with the robust and every factor is too large. The curve overstates survival by 0.046 at $t = 1.5$, about a sixth of the true value. When the robust leave, it understates by 0.058, more than a fifth. The bias matches the computed limit to the third decimal, so it is a property of the estimand, not of small samples. More data would estimate the wrong curve more precisely. No test on the observed data can detect it, since the data identify only the crude hazard; Censoring, Survival Functions and Hazards proves this nonidentifiability (Theorem 6, after Tsiatis).

What is proved, what is cited, what the experiment shows

Proved here. The product formula's use of the discrete hazards and the estimator itself; the nonparametric maximum likelihood property with its uniqueness up to the largest observation (Theorem 1); the reduction to the empirical survival function and the binomial variance without censoring (Theorem 2); Kaplan–Meier below the exponential of Nelson–Aalen (Theorem 3); the exact mean and variance of the error $\hat H - H^*$ of the Nelson–Aalen estimator in a discrete-time model, where $H^*$ sums the hazards over the times at which someone was at risk, by uncorrelated martingale increments (Theorem 4); the median's interval as the plain pointwise interval at the median (Proposition 1). Greenwood's formula and the log and log-log intervals are derived by the delta method, with the heuristic steps named. The heuristic variance integral and the limit under informative censoring are derivations, not theorems.

Cited. The product formula for a discrete survival function, the likelihood of censored data, $S = e^{-H}$ for continuous lifetimes and the nonidentifiability of dependent censoring (Censoring, Survival Functions and Hazards); the limiting normality of the product-limit estimate for a continuous survival distribution, and the near-correctness of Greenwood's formula for the actuarial life table (Breslow and Crowley, 1974, abstract); the counting-process theory of the Nelson–Aalen estimator, consistency and weak convergence (Aalen, 1978), developed at book length by Andersen, Borgan, Gill and Keiding (1993); the asymptotic optimality of the product-limit estimator, in the sense of a Hájek–Beran representation theorem and asymptotic minimax (Wellner, 1982); the median's interval (Brookmeyer and Crowley, 1982).

Computed. The 6-MP and NHANES figures are exact computations, the 6-MP ones in exact fractions where shown. The coverage and informative-censoring results are seeded simulations reported as medians and interquartile ranges over 30 runs, and they describe the distributions simulated.

Worked problems

These problems were written for this article; they use the 6-MP trial and small invented samples. The script tools/experiments/statistics/kaplan-meier-estimator.py recomputes every number.

Problem 1 (a log-log interval by hand). Compute the 95% log-log interval for $S(16)$ in the 6-MP group.

Solution. The interval is 0.368 to 0.805.

From the table, $\hat S(16) = (18/21)(16/17)(14/15)(11/12)(10/11) = 0.6275$. Greenwood's sum adds $d_j/[n_j(n_j - d_j)]$ over weeks 6, 7, 10, 13 and 16: $3/(21 \cdot 18) + 1/(17 \cdot 16) + 1/(15 \cdot 14) + 1/(12 \cdot 11) + 1/(11 \cdot 10) = 0.03304$, so $\hat\sigma = 0.1818$. Then $\ln\hat S = -0.4661$ and $z\hat\sigma/\ln\hat S = 1.96 \times 0.1818/(-0.4661) = -0.7644$. The exponents are $e^{0.7644} = 2.1477$ for the lower end and $e^{-0.7644} = 0.4656$ for the upper end, so the interval is $0.6275^{2.1477} = 0.368$ to $0.6275^{0.4656} = 0.805$. Both ends are inside $(0, 1)$, as they must be.

Problem 2 (Kaplan–Meier against the exponential of Nelson–Aalen). For the placebo group at 8 weeks, compute both estimates of $S(8)$ and explain the gap.

Solution. $\hat S(8) = 0.3810$ and $e^{-\hat H(8)} = 0.4229$.

The event times up to 8 weeks are 1, 2, 3, 4, 5 and 8, with $(n_j, d_j) = (21, 2), (19, 2), (17, 1), (16, 2), (14, 2), (12, 4)$. By Theorem 2, $\hat S(8) = 8/21 = 0.3810$. The Nelson–Aalen sum is $2/21 + 2/19 + 1/17 + 2/16 + 2/14 + 4/12 = 0.8605$, and $e^{-0.8605} = 0.4229$. Theorem 3 says the first is smaller. The gap is large because the factors are large: at 8 weeks a third of those at risk relapse, and $1 - 1/3 = 0.667$ against $e^{-1/3} = 0.717$. When each step is a small fraction of the risk set, as in the NHANES data, the two estimates agree to three decimals.

Problem 3 (the median's interval for placebo). Find the median of the placebo group and its Brookmeyer–Crowley interval.

Solution. The median is 8 weeks, with interval 4 to 11 weeks.

Without censoring, $\hat S(t)$ is the share still in remission and Greenwood's variance is $\hat S(1 - \hat S)/21$ (Theorem 2). The shares after the event times 3, 4, 5, 8, 11 and 12 weeks are 16/21, 14/21, 12/21, 8/21, 6/21 and 4/21. The first share at or below one half is $8/21 = 0.381$, at 8 weeks, so $\hat m = 8$. The test of $S(t) = 1/2$ uses $z = (\hat S - 1/2)/\sqrt{\hat S(1 - \hat S)/21}$. At 3 weeks $\hat S = 0.762$ and $z = 2.82$, rejected. At 4 weeks $\hat S = 0.667$ and $z = 1.62$, accepted. At 5, 8 and 11 weeks $z = 0.66$, $-1.12$ and $-2.17$ (the last rejected, since $\hat S = 0.286$ and $\sqrt{0.286 \times 0.714/21} = 0.0986$). The accepted event times are 4, 5 and 8 weeks, so the interval runs from 4 weeks to the next event time after 8, which is 11 weeks.

Problem 4 (censoring in the middle). Five machines fail or are withdrawn at 1, 2+, 3, 4+ and 5 hours. Compute $\hat S$, and check on this example that moving each censored observation's mass equally onto the observations to its right reproduces the jumps.

Solution. $\hat S(1) = 4/5$, $\hat S(3) = 8/15$, $\hat S(5) = 0$.

At 1 hour all 5 are at risk and one fails: $4/5$. The machine withdrawn at 2 hours leaves, so at 3 hours 3 are at risk and one fails: $(4/5)(2/3) = 8/15$. The machine withdrawn at 4 leaves, and at 5 hours the one machine at risk fails: $\hat S(5) = 0$. The estimate puts mass $1/5$ at 1, $4/5 - 8/15 = 4/15$ at 3 and $8/15$ at 5. Without the withdrawals each failure would carry $1/5$. The machine withdrawn at 2 hours had mass $1/5$ to give; it is shared equally among the 3 machines observed after it, $1/15$ each. The failure at 3 then carries $1/5 + 1/15 = 4/15$. The two machines remaining after 3 hours hold $2(1/5 + 1/15) = 8/15$. The one withdrawn at 4 passes its share to the single machine after it, which fails at 5 with mass $8/15$. Moving each censored observation's mass equally onto the observations to its right reproduces the Kaplan–Meier jumps exactly here.

Summary

Result Statement
Estimator $\hat S(t) = \prod_{t_{(j)} \le t}(1 - d_j/n_j)$, censored observations at risk up to their time
Maximum likelihood $\hat S$ maximizes the censored-data likelihood over all distributions; unique up to $y_{\max}$
No censoring $\hat S$ = share surviving; Greenwood = $\hat S(1 - \hat S)/n$
Nelson–Aalen $\hat H(t) = \sum d_j/n_j$; $\hat S \le e^{-\hat H}$
Discrete-time variance $\operatorname{Var}(\hat H - H^*) = \sum E[h(1 - h)\mathbf{1}\{N > 0\}/N]$, exactly
Greenwood $\widehat{\operatorname{Var}}\hat S = \hat S^2\sum d_j/[n_j(n_j - d_j)]$ (delta method)
Log-log interval $\hat S^{\exp(\pm z\hat\sigma/\ln\hat S)}$, inside $(0, 1)$
Median first $t$ with $\hat S(t) \le 1/2$; interval by inverting tests of $S(t) = 1/2$
Informative censoring $\hat S \to \exp(-\int h^\#)$, the crude hazard's curve

What we have learned

The Kaplan–Meier estimator multiplies, at each event time, the share of those still observed who survive it. That product is the distribution that makes the observed deaths and survivals most probable among all distributions, and without censoring it is simply the share of survivors. Its variance comes from a sum of uncorrelated martingale increments, exactly for the Nelson–Aalen estimator in discrete time and by the delta method for Greenwood's formula. In the simulations the log-log interval was near 95% across the curve with 200 observations, and with 50 everywhere except the far tail. On the NHANES data the estimator raised the three-year risk of death for the 2017 to 2018 adults from a naive 2.22% to 3.05%. For the 1999 to 2000 cohort it gave twenty-year survival of 0.341 with diagnosed diabetes and 0.737 without. Its guarantee rests on independent censoring: when the frail or the robust leave early, it converges to a different curve.

Is the gap between the diabetes curves larger than chance would produce, and how much of it is age? That is the question of The Log-Rank Test, which compares two curves one event time at a time.

References