Skip to main content

Welcome to a Grasp lesson

Create a free account to keep studying and create your own study path.

Lesson 20

Kaplan-Meier Survival Analysis

Recommended resources

Introduction

In our last lesson, we established the fundamental challenge of survival analysis: our data is often incomplete due to censoring. You learned to identify right, left, and interval censoring, and we discussed the critical assumption of non-informative censoring that underpins most survival methods. Now, we move from identifying the problem to solving it.

This lesson introduces the Kaplan-Meier estimator, one of the most important and widely used tools in survival analysis. It provides a non-parametric way to estimate the survival function directly from time-to-event data, even when that data includes right-censored observations. Your goal is to master the construction of this estimate, understanding both its intuitive foundation and the practical steps of its calculation. This is a core skill for the CS2 exam and for any practical work in this field.


From Empirical Estimates to Conditional Survival

Before tackling censoring, let's consider a simple case. If we had a complete dataset with no censored observations, how would we estimate the survival function ? As a statistician, your immediate thought would likely be to use the empirical survival function:

This is a straightforward and intuitive estimator. However, as soon as right-censoring is introduced, this simple fraction becomes problematic. If an individual is censored at time , we know they survived up to , but we don't know for how much longer. We cannot simply exclude them from the numerator, as that would underestimate survival, nor can we treat them as if they had the event at time , which would also be incorrect.

The ingenious solution proposed by Kaplan and Meier in 1958 is to reframe the problem using conditional probabilities. The probability of surviving beyond time can be expressed as a product of conditional probabilities of surviving through a series of smaller time intervals. Let be the distinct times at which events (e.g., deaths) occur. The survival function at time can be written as:

The Kaplan-Meier estimator is built by estimating each of these conditional probabilities from the data and multiplying them together. This is why it is also known as the product-limit estimator.

The following resource provides an excellent intuitive motivation for this approach.

[PDF] Estimating the Survival Function

This document from the University of Michigan introduces the Kaplan-Meier estimator by first considering the simple case without censoring and then extending the logic to handle censored data using conditional probabilities.

Please read the first two main sections. Start at the beginning and read through the Motivation section, which introduces the empirical survival function for uncensored data. Then, read the section that applies these ideas to survival estimation, from the 'Now, let's apply' section. Focus on how the survival probability is broken down into a product of conditional probabilities. This is the conceptual heart of the KM method.


Constructing the Kaplan-Meier Estimate

The logic of conditional probability leads to the Kaplan-Meier formula. The estimate of the survival function is given by:

Let's break down the components of this formula:

  • The product is taken over all distinct event times that are less than or equal to the time you are evaluating.
  • is the number of individuals who experience the event (e.g., die) at time .
  • is the number of individuals who are at risk of experiencing the event just before time . This includes everyone who has not yet had the event and has not yet been censored.

The term is the empirical estimate of the conditional probability of having the event at time , given survival up to . Therefore, is the estimated probability of surviving past time , given survival up to that point. The overall survival probability is the cumulative product of these conditional survival probabilities up to time .

The following video provides a clear, step-by-step demonstration of how to apply this formula to a sample dataset.

Kaplan-Meier Estimation [Survival Analysis]

This video, "Kaplan-Meier Estimation" from the channel math et al, walks through a complete calculation of the KM estimator.

Please watch the following segments: First, watch the introduction to the formula, where the narrator defines the key terms d_j and Y_j (which is the same as our n_j). Next, watch the detailed worked example. Pay close attention to how the number at risk (Y_j) is updated at each step and how censored observations are handled—they are removed from the risk set for subsequent calculations but do not cause a drop in the survival curve themselves.

A Worked Example in Tabular Form

The most common way to perform a Kaplan-Meier calculation by hand is by constructing a "life table". Let's walk through an example.

Suppose we have the following data for 13 subjects in a study, where + denotes a right-censored observation: 3, 4, 4, 6, 7, 7, 8, 8+, 10, 11, 13, and two censored observations at time 5 (let's say we just know they were lost after time 4 and before time 6, so they affect the risk set at time 6). This is a slightly modified dataset to better illustrate the process.

Step 1: Order the distinct event times.
The times at which deaths occur are: 3, 4, 6, 7, 8, 10, 11, 13.

Step 2: Create the Kaplan-Meier table.
We construct a table with the following columns:

  • time (): The distinct event times.
  • m (): Number of events (deaths) at time .
  • q (): Number of individuals censored in the interval since the last event.
  • n (): Number of individuals at risk just before time .
  • : Conditional survival probability.
  • : Kaplan-Meier estimate of survival.

Let's build the table row by row.

time () m () q () n () Calculation
0 0 0 13 13/13 = 1.0 1.0 1.0
3 1 0 13 12/13 0.923 1.0 * (12/13)
4 2 0 12 10/12 0.769 0.923 * (10/12)
6 1 2* 9 8/9 0.684 0.769 * (8/9)
7 2 0 8 6/8 0.513 0.684 * (6/8)
8 1 1** 6 5/6 0.427 0.513 * (5/6)
10 1 0 4 3/4 0.321 0.427 * (3/4)
11 1 0 3 2/3 0.214 0.427 * (2/3)
13 1 0 2 1/2 0.107 0.214 * (1/2)

Explanation of the rows:

  • At time 0: Everyone (13) is at risk. .
  • At time 3: One event occurs. 13 people were at risk. . The number at risk for the next step is .
  • At time 4: Two events occur. 12 people were at risk. . The number at risk for the next step is .
  • At time 6: One event occurs. However, two people were censored at time 5. They are counted in the risk set up to time 4, but are removed before the calculation at time 6. So, the number at risk at time 6 is . Whoops, my manual example has a slight inconsistency with the image. Let's follow the logic of the image below which is cleaner. The key is that n for a row is the n from the previous row minus the previous m and q. So at time 6, n should be 12-2 = 10? No, wait. The q column is the number censored in the interval. Let's use the standard definition: . Let's re-examine the image logic.

The image below shows the calculation for a similar dataset and provides a very clear visual of the iterative process.

This image displays the step-by-step calculation of a Kaplan-Meier survival curve. On the left is a life table with columns for time, number of events (m), number of censored observations (q), and number at risk (n). On the right, it shows how the survival function S(t) is calculated iteratively by multiplying the previous survival probability by the conditional probability of survival at the current time step, which is (n-m)/n.

Looking at the image table:

  • At time 4, n=12, m=2, q=1. So the risk set for the next event time (6) is n=12-2-1=9. This matches the image.
  • The conditional survival is (n-m)/n. So at time 4, it's (12-2)/12 = 10/12.
  • The cumulative survival is the previous times the current conditional survival. So at time 4, it's . This is the core mechanic.

Properties and Justifications of the KM Estimator

As a statistician, you might be interested in the theoretical underpinnings of the KM estimator. While we are focusing on application, it's useful to know that the KM estimator is not just an intuitive hack; it is also the Non-Parametric Maximum Likelihood Estimator (NPMLE) of the survival function. This means that under the assumption of non-informative censoring, no other non-parametric estimate is more likely to have generated the observed data.

Another elegant way to conceptualize the estimator is through Efron's "Redistribution of Mass" algorithm:

  1. Assign an initial probability mass of to each of the subjects.
  2. Move along the time axis. Whenever you encounter a censored observation, take its probability mass and redistribute it equally among all individuals who are still at risk at that time (i.e., all observations to its right).
  3. The final mass at each uncensored event time represents the probability of the event occurring at that time, which can be used to construct the survival function.

The document below provides a concise summary of these justifications and presents a clear, worked example that is very similar to the format required in exams.

[PDF] STAT331: Unit 3 Kaplan-Meier (KM) Estimator Introduction

This document from Stanford University provides a more formal, yet accessible, introduction to the Kaplan-Meier estimator.

Please review the following sections: Read the introduction on pages 1-2. This part provides the heuristic derivation based on discrete hazards, which is equivalent to our conditional probability argument. Note that Y(v_j) here is the same as our n_j. Study the worked example on page 3. This table format is a perfect model for solving problems. Pay special attention to Note 1, which explains what happens when the largest observation is censored: the survival curve does not go to 0 and is considered undefined beyond that point. Skim the sections on the general case and Efron's algorithm on pages 4-6. You don't need to master the derivations, but understanding these alternative justifications deepens your grasp of the estimator's properties.

The result of a Kaplan-Meier analysis is a step function that is right-continuous. It starts at 1, stays flat between events, and drops vertically at each time an event occurs. The size of the drop depends on both the number of events and the number of people at risk at that time.


Try It Yourself

To solidify your understanding, let's begin solving a problem. This is from an exercise in the Stanford PDF.

Data (n=21): 6, 6, 6, 6+, 7, 9+, 10, 10+, 11+, 13, 16, 17+, 19+, 20+, 22, 23, 25+, 32+, 32+, 34+, 35+

Let's construct the first few rows of the KM table.

  1. Distinct event times: 6, 7, 10, 13, 16, 22, 23.
  2. Initial state: At time , , .
  3. First event time, :
    • Number of events (three individuals die at time 6).
    • Number censored in is (the one at 6+).
    • Number at risk .
    • .
  4. Second event time, :
    • Number at risk : We started with 21. Before time 7, we lost 3 to events and 1 to censoring at time 6. So, .
    • Number of events .
    • .

I encourage you to try and complete the table for the remaining event times as practice.


Conclusion

In this lesson, you've learned the mechanics and intuition behind the Kaplan-Meier estimator, a cornerstone of modern survival analysis.

Key Takeaways:

  • The Kaplan-Meier estimator is a non-parametric method to estimate the survival function from right-censored data.
  • It is based on the product-limit formula, which multiplies conditional probabilities of surviving successive time intervals defined by observed events.
  • The calculation is performed iteratively using a life table, where at each event time , the survival probability is updated by the factor .
  • Censored observations do not cause a drop in the survival curve, but they reduce the number of individuals at risk () for subsequent time points.
  • The resulting is a right-continuous step function. If the last observation is censored, the curve does not drop to zero.

You now have the tool to derive a survival curve from raw data. However, an estimate is incomplete without a measure of its uncertainty. In our next lesson, we will address this by learning how to calculate confidence intervals for the Kaplan-Meier estimate using Greenwood's formula.