Kaplan–Meier Survival Analysis
A nonparametric survival analysis method that estimates the probability that the event of interest has not yet occurred as time passes.
Suppose you want to know how long patients who received a certain treatment survive, when customers cancel a service after signing up, or how long a machine runs after installation before it breaks down.
In problems like these, it is not enough to simply check whether the event occurred. The time it took for the event to occur is also an important thing to analyze.
For example, even if two customers both canceled the service, if one canceled 2 months after signing up and the other used the service for 24 months before canceling, there is a big difference in how long each kept using it.
There is an even more important problem. For customers who are still keeping the service at the end of the study, we cannot know exactly when they will cancel. Excluding these customers from the analysis can lead to a wrong estimate of how long the service is used.
The method that analyzes whether an event occurred together with the time until it occurred is survival analysis, and the most representative nonparametric method among them is the Kaplan–Meier estimator.
The Kaplan–Meier estimator estimates the probability that the event of interest has not yet occurred as time passes. It can analyze not only patient survival time but also the time until many kinds of events, such as customer churn, machine failure, reemployment, and contract termination.
In this article, we cover the Kaplan–Meier estimator from its basic concepts to censoring, calculating survival probabilities, interpreting the survival curve, the median survival time, comparing groups, a worked example, and points to watch out for.
Understanding the Kaplan–Meier estimator and survival analysis
What is the Kaplan–Meier estimator?
The Kaplan–Meier estimator is a nonparametric survival analysis method that estimates the probability of remaining event-free over time.
In survival analysis, the word "survival" does not necessarily mean a person staying alive. It means the state in which the event defined by the analyst has not yet occurred. For example, if the event in a customer churn analysis is defined as "canceling the service," the survival probability is the probability that a customer has not canceled the service by a given time.
If a medical study defines the event as "death," it is the probability of being alive at a given time. In a machine failure study, it is the probability that the machine has not broken down by that time. The core of the Kaplan–Meier estimator is updating the survival probability step by step at each time an event occurs.
This method does not assume that event times follow a specific probability distribution such as the normal or exponential distribution. So it can be used even when it is hard to know the distribution of event times in advance.
However, it does require assumptions, such as how censoring relates to the process by which events occur. Being a nonparametric method does not make it free of all assumptions.
How does survival analysis differ from ordinary statistical analysis?
An ordinary analysis checks whether a certain outcome occurred or what its value is.
For example, if 200 of 1,000 customers canceled the service, the cancellation rate is 20%. But this number alone does not tell you how long after signing up the customers canceled. Even two groups with the same cancellation rate can differ: in one group most customers cancel in the first month after signing up, while in the other they cancel after two years.
Also, each customer may have been observed for a different length of time. Simply treating a customer observed from the start of the study the same as one who signed up just before the study ended can cause problems. Survival analysis takes these differences into account when analyzing the time until the event.
| Aspect | Ordinary proportion analysis | Kaplan–Meier Survival Analysis |
|---|---|---|
| Main question | How many events occurred? | Until when has the event not occurred? |
| Main data | Whether the event occurred | Time to event and whether it occurred |
| Observation period | May not be fully accounted for in a simple analysis | Uses time information directly |
| Censoring | Hard to handle with ordinary proportion analysis alone | Can account for censoring |
| Typical results | Incidence, proportion | Survival probability, survival curve, median survival time |
The Kaplan–Meier estimator is more useful than simply calculating the proportion of events for understanding in detail how events occur over time.
What is an event?
In survival analysis, an event is the outcome whose timing the researcher wants to analyze.
An event does not have to be a negative outcome. Depending on the purpose of the study, positive outcomes such as recovery after treatment, reemployment, or reaching a goal can also be defined as events.
| Field | Event | Time to event |
|---|---|---|
| Medicine | Death | From start of treatment to death |
| Medicine | Disease recurrence | From end of treatment to recurrence |
| Marketing | Service cancellation | From sign-up to cancellation |
| HR | Employee departure | From hiring to departure |
| Manufacturing | Equipment failure | From installation to failure |
| Labor economics | Reemployment | From job loss to reemployment |
For example, in a customer churn study, you can define the date the customer signed up as the start time and the date they canceled the service as the event time. If a customer has not canceled, you record the time up to the last point they were observed. What matters is that the event and the start of observation must be clearly defined before the analysis begins.
For example, the results will differ depending on whether you define the event as "canceling the service" or as "not using the service for 30 days or more." Also, when the same customer signs up and cancels several times, a simple analysis of the first event alone may not be enough.
The concept and types of censoring
What is censoring?
One of the most important concepts for understanding Kaplan–Meier analysis is censoring.
Censoring means that we did not observe exactly when the event of interest occurred. For example, suppose a customer used the service for 12 months after signing up and had not canceled by the end of the study. We cannot know whether this customer will keep the service from now on.
However, we do know the fact that they did not cancel the service at least during the 12 months observed. Such a customer is called an observation that is right-censored at 12 months.
Example data
| Customer | Observation period | Canceled? | Status in the analysis |
|---|---|---|---|
| A | 3 months | Canceled | Event |
| B | 6 months | Kept | Censoring |
| C | 9 months | Canceled | Event |
| D | 12 months | Kept | Censoring |
| E | 15 months | Canceled | Event |
Customer B used the service for 6 months, but whether they canceled afterward was not observed. So customer B should not be treated as a customer who canceled at 6 months.
But excluding them from the analysis entirely is not appropriate either, because the information that customer B kept the service for at least 6 months can be used to estimate the survival probability. The Kaplan–Meier estimator takes this censoring information into account when calculating survival probabilities.
What types of censoring are there?
In survival analysis, censoring can be classified by the range in which the unobserved event time lies.
Right censoring
The event has not occurred by the time observation ends. Examples are a patient who is still alive at the end of the study or a customer who has kept the service. The Kaplan–Meier estimator generally handles this kind of right-censored data.
Left censoring
We know the event occurred before a certain time but do not know exactly when. For example, at the first examination a condition is found to have already occurred, but the date it occurred is unknown.
Interval censoring
We only know that the event occurred between two observation times. For example, if a disease was not found at the 3-month checkup but was found at the 6-month checkup, the onset lies between the two checkups.
The standard Kaplan–Meier estimator is meant for data with exact event times or right-censoring times. For left- or interval-censored data, you should use a separate survival analysis method suited to that structure.
Calculating survival probabilities, with a worked example
How is the Kaplan–Meier survival probability calculated?
At each time an event occurs, the Kaplan–Meier estimator calculates the proportion of subjects who remained event-free up to that time and did not have the event.
Multiplying these conditional survival probabilities in order gives an estimate of the cumulative survival probability up to a given time. The formula is as follows.
S(t) = ∏(1 - dᵢ / nᵢ)
Here, each symbol means the following.
- S(t): the survival probability that the event has not occurred by time t
- dᵢ: the number of observations that had the event at that time
- nᵢ: the number of observations in the risk set just before that time
- ∏: multiply together the conditional survival probabilities at all event times
The risk set is the people or subjects who, just before a given event time, have not yet experienced the event and are still under observation. For example, if there were 100 customers at first and 10 canceled at the first event time, the conditional survival probability at that time is as follows.
(100 - 10) ÷ 100 = 0.90 So the cumulative survival probability at the first event time is 90%. When more events occur later, you multiply the cumulative survival probability so far by the new conditional survival probability.
This is why the Kaplan–Meier estimator is also called the product-limit estimator.
Worked example: service retention of 10 customers
Suppose we observed 10 customers for the time from signing up for a service until canceling it.
Some customers canceled the service during the observation period, while others had not canceled when the study ended or dropped out of follow-up. The table below lists the events and censoring in time order.
| Time (months) | Customers canceling | Customers censored | Risk set just before |
|---|---|---|---|
| 2 | 1 | 0 | 10 |
| 4 | 2 | 0 | 9 |
| 5 | 0 | 1 | 7 |
| 6 | 1 | 0 | 6 |
| 7 | 0 | 2 | 5 |
| 9 | 1 | 0 | 3 |
| 12 | 0 | 2 | 2 |
At 2 months, 1 of the 10 in the risk set canceled. So the survival probability is: S(2) = 9 / 10 = 0.90
At 4 months, 2 of the 9 in the risk set canceled. So the cumulative survival probability up to 4 months is: S(4) = 0.90 × (7 / 9) = 0.70
At 5 months, 1 customer was censored. Censoring itself does not lower the survival probability, but that customer is removed from later risk sets. At 6 months, 1 of the 6 in the risk set canceled. S(6) = 0.70 × (5 / 6) ≈ 0.583
At 7 months, 2 customers were censored, and at 9 months, 1 of the 3 remaining in the risk set canceled. S(9) = 0.583 × (2 / 3) ≈ 0.389 So in this data, the estimated probability of not canceling the service by 9 months is about 38.9%.
Kaplan–Meier estimates
| Time | Risk set | Cancellations | Cumulative survival probability |
|---|---|---|---|
| Start | 10 | 0 | 100.0% |
| 2 months | 10 | 1 | 90.0% |
| 4 months | 9 | 2 | 70.0% |
| 6 months | 6 | 1 | 58.3% |
| 9 months | 3 | 1 | 38.9% |
What matters in this result is that censored customers are not counted as if they had canceled. Also, since only 3 people remained in the risk set at 9 months, the uncertainty of the survival estimate there can be larger than at earlier times.
Interpreting the Kaplan–Meier survival curve
The typical output of a Kaplan–Meier analysis is the survival curve.
The survival curve shows the estimated probability that the event has not yet occurred as time passes. The horizontal axis shows the time until the event, and the vertical axis shows the survival probability. The Kaplan–Meier curve calculated from the 10-customer data above looks like this.
The survival curve usually starts at 100% and steps down each time an event occurs. During periods with no events, the survival probability stays constant. Censoring is usually shown as small marks on the curve. The survival probability does not drop at censoring times.
If the curve drops quickly, many events of interest occurred in a relatively short time. Conversely, if the curve stays high for a long time, many subjects went a relatively long time without the event.
However, be careful when interpreting the later part of the survival curve, because the remaining risk set can become very small.
Median and mean survival time
What is the median survival time?
The median survival time is the first time at which the Kaplan–Meier survival probability falls to 50% or below.
For example, if the survival probability of patients who received a certain treatment is 60% at 12 months and 45% at 18 months, the median survival time is the event time in between at which the survival curve first falls to 50% or below. The median survival time is different from the simple median of all observations.
This is because the Kaplan–Meier estimator estimates the survival function while accounting for censoring and determines the median survival time from that survival function. In the 10-customer example calculated above, the survival probability is about 58.3% at 6 months and about 38.9% at 9 months.
So the Kaplan–Meier estimate of the median service retention time is 9 months. This does not mean that exactly half the customers canceled at 9 months.
It means the estimated survival probability first fell to 50% or below at 9 months.
Also, if the survival curve does not fall to 50% or below by the end of the study, the median survival time cannot be estimated. In that case, you can report it as "median survival time not reached."
How do mean and median survival time differ?
Mean and median survival time both summarize the time until the event, but they mean different things.
The median survival time is the time at which the estimated survival probability first falls to 50% or below. The mean survival time, on the other hand, is related to the area under the survival curve. But with survival data that include censoring, the mean of the full survival time is often hard to estimate.
In particular, if many subjects have not had the event by the end of observation, the distribution of survival times beyond that point is unknown. In this situation, you can use the restricted mean survival time (RMST).
RMST calculates the area under the survival curve up to a specific time, summarizing the expected event-free time within a fixed observation window.
| Aspect | Meaning |
|---|---|
| Median survival time | The time at which the survival probability first falls to 50% or below |
| Mean survival time | Expected value of the full survival time distribution |
| RMST | Restricted mean survival time up to a fixed time |
If the median survival time cannot be calculated from the Kaplan–Meier results, or if the difference in survival time within a set observation window matters, you can additionally consider RMST.
Comparing Kaplan–Meier curves by group
The Kaplan–Meier estimator can be used not only for a single group but also to calculate a separate survival curve for each of several groups.
For example, suppose we compare service retention between customers on monthly contracts and customers on annual contracts. Plotting the two groups' survival curves on the same graph shows how the probability of keeping the service changes over time. Suppose the results are as follows.
| Time | Monthly contract | Annual contract |
|---|---|---|
| 3 months | 85% | 96% |
| 6 months | 72% | 92% |
| 12 months | 55% | 84% |
| 18 months | 43% | 76% |
| 24 months | 34% | 68% |
In these results, annual-contract customers had a higher probability of keeping the service than monthly-contract customers at every time point. For example, the probability of keeping the service at 12 months is 55% for monthly-contract customers and 84% for annual-contract customers.
So we can say that annual-contract customers tended to keep the service relatively longer during the analysis period.
However, the fact that the two groups' survival curves look different does not by itself let us conclude that a statistically significant difference exists.
Also, factors such as contract type, how long customers have used the service, price, and their reason for using it may all be related, so we should not conclude that contract type itself causes the difference in churn.
Log-rank test
The log-rank test is the standard method for testing whether survival curves differ between two or more groups.
If the Kaplan–Meier estimator estimates each group's survival probability, the log-rank test is used to test the null hypothesis that the groups have the same survival experience. For example, when comparing service retention between monthly-contract and annual-contract customers, you can set up the following hypotheses.
- Null hypothesis (H₀): The two groups have the same survival function.
- Alternative hypothesis (H₁): The two groups' survival functions are not the same.
At each event time, the log-rank test compares the observed number of events with the expected number of events based on the size of each group's risk set. For example, suppose the log-rank test gives a p-value of 0.003. With a significance level of 0.05, you can reject the null hypothesis that the two groups have the same survival function.
But a small p-value does not mean that one group's survival probability is necessarily higher at every time point. Also, the log-rank test tests the difference over the whole observation period; it does not directly estimate the difference in survival probability at a specific time or the size of the difference in survival time.
When survival curves cross or the hazard ratio changes over time, the log-rank test can lose power.
Comparing Kaplan–Meier estimation and Cox regression
The Kaplan–Meier estimator and Cox proportional hazards regression are both used in survival analysis, but they serve different purposes.
The Kaplan–Meier estimator mainly estimates the survival function of one group or several groups. Cox regression, on the other hand, considers several explanatory variables together to analyze how a particular variable relates to the risk of the event.
For example, when analyzing customers' service retention, you can use the Kaplan–Meier estimator to compare the survival curves of monthly-contract and annual-contract customers. But if you want to consider several variables at once, not just contract type but also how long customers have used the service, monthly fee, frequency of use, and age, you can use Cox regression.
| Aspect | Kaplan–Meier estimation | Cox proportional hazards regression |
|---|---|---|
| Main purpose | Estimating survival probability over time | Analyzing the relationship between explanatory variables and the risk of the event |
| Main results | Survival curve, survival probability at each time, median survival time | Regression coefficients, hazard ratio (HR), confidence intervals |
| Adjusting for several variables at once | Not done by the basic method itself | Possible |
| Typical use | Comparing survival time between groups | Risk analysis adjusted for other factors |
| Main assumptions | Noninformative censoring, etc. | Proportional hazards assumption, etc. |
So the Kaplan–Meier estimator is useful if you simply want to see which group keeps the service longer. If you want to analyze the relationship with the risk of the event while statistically accounting for the effects of other variables, you can additionally consider a method such as Cox regression.
Key assumptions of Kaplan–Meier analysis
The Kaplan–Meier estimator does not assume a specific distribution for event times, but a few conditions must be checked before you can trust the results.
Censoring must be noninformative.
Under appropriate conditions, the event process of censored subjects must be comparable to that of subjects who remain under observation. For example, a problem arises if customers who are very dissatisfied with the service drop out of follow-up more often, and these customers are also more likely to cancel the service sooner.
In this case, censoring is related to the likelihood of the event, and the Kaplan–Meier estimates can be biased.
Event times and censoring times must be recorded accurately.
The Kaplan–Meier estimator calculates survival probabilities based on the times events occur. So the sign-up date or treatment start date, event date, last observation date, and so on must be recorded accurately. The time unit (days, weeks, months, etc.) must also be defined consistently.
The independence of observations must be considered.
Standard Kaplan–Meier analysis often assumes the event times of independent subjects. For example, if several service contracts of the same customer are each treated as an independent customer, the relationship between observations can affect the results.
For such data, you may need a separate method that accounts for recurrent events or a clustered structure.
The event must be clearly defined.
Mixing different events, such as service cancellation, a temporary pause in use, and a payment failure, into one outcome can make the meaning of the survival probability unclear. So the definition of the event and the start of observation must be set clearly before the analysis.
Confidence intervals and number at risk for the survival curve
Why do confidence intervals matter for the survival curve?
The survival probability calculated with the Kaplan–Meier estimator is an estimate based on a sample.
So there is no guarantee that it matches the true survival probability of the population exactly. To express the uncertainty of this estimate, you can use a confidence interval. For example, suppose the survival probability at 12 months is 70% and the 95% confidence interval is 63% to 77%.
This expresses, as an interval, the uncertainty about the 12-month survival probability under the statistical method and assumptions used. Confidence intervals are especially important in the later part of the observation period, because over time the number of subjects remaining in the risk set shrinks due to events and censoring.
For example, if 500 people remained in the risk set at 3 months but only 15 remained at 36 months, the survival estimate in the later part can be quite unstable. So when presenting a survival curve, it is good to show the 95% confidence interval and the number at risk together whenever possible.
How do you read the number at risk?
A Kaplan–Meier graph often includes a table below it showing the number at risk at each time.
The number at risk is the number of subjects who, just before a given time, have not yet experienced the event and remain in follow-up. For example, suppose we have the following results.
| Time | Monthly contract | Annual contract |
|---|---|---|
| Start | 250 | 250 |
| 6 months | 180 | 225 |
| 12 months | 120 | 195 |
| 18 months | 70 | 160 |
| 24 months | 30 | 125 |
In these results, at 24 months, 30 monthly-contract customers and 125 annual-contract customers remain in the risk set. The later survival probabilities of the monthly-contract group may be estimated from a relatively small number of customers.
So if the survival curve changes a lot in its later part, you should also check how many customers actually remain in the risk set. Note, however, that the number at risk decreases not only because of events but also because of censoring.
So a drop in the number at risk from 250 to 120 does not mean that all 130 canceled the service.
Points to watch in Kaplan–Meier analysis
The Kaplan–Meier estimator is useful for analyzing the time until an event, but a few points require caution.
Do not treat censoring as an event.
A customer who kept the service until the end of observation is not a customer who canceled. Treating customers whose cancellation was not confirmed as events can lead to wrong survival estimates.
Do not confuse the survival probability with a simple proportion of remaining customers.
The Kaplan–Meier survival probability is estimated by accounting for the risk set and censoring. So it can differ from the proportion obtained by simply dividing the number of customers observed up to a given time by the initial number of customers.
If the survival curve does not fall to 50% or below, the median survival time cannot be calculated.
If the survival probability stays above 50% throughout the observation period, the median survival time has not been reached. In this case, do not arbitrarily report the last observation time as the median survival time.
Survival probabilities in the later part can be unstable.
The longer the observation period, the fewer subjects may remain in the risk set. So when interpreting the last section of the survival curve, check the confidence interval and the number at risk.
A difference between groups does not imply a causal effect.
For example, even if annual-contract customers show higher survival probabilities than monthly-contract customers, we cannot conclude that contract type directly caused the difference. Other factors, such as customers' reasons for signing up, price, or usage habits, may also be involved.
You may need to account for competing events.
When another kind of event prevents the event being analyzed from occurring, standard Kaplan–Meier analysis alone may not properly estimate the cumulative incidence of the event of interest. For example, when death from a specific cause is defined as the event, death from other causes makes the event of interest impossible.
In such situations, you should consider competing risks analysis and the cumulative incidence function.
Reporting Kaplan–Meier results
When reporting Kaplan–Meier results, it is good to present the total sample size, number of events, number censored, observation period, survival probabilities at key times, and median survival time together.
If you compared groups, report each group's survival probabilities and numbers at risk, and add the log-rank test results as needed. Using the 10-customer data above, you could write it as follows.
Example report
A Kaplan–Meier survival analysis was conducted to analyze the time from customers' sign-up to service cancellation. Of the 10 customers, service cancellation was observed for 5, and the remaining 5 were censored during the observation period. The Kaplan–Meier estimates of the probability of keeping the service were 90.0% at 2 months, 70.0% at 4 months, 58.3% at 6 months, and 38.9% at 9 months. The median service retention time was estimated at 9 months. This means the estimated probability of keeping the service first fell to 50% or below at 9 months.
In real studies, when the sample size is very small, the uncertainty of the survival probabilities can be large, so check the confidence intervals and the number at risk as well. It is also good to report clearly how censoring was defined and how the event and the start of observation were set.
Where the Kaplan–Meier estimator is used
The Kaplan–Meier estimator is used in many fields that need to analyze the time until a particular event occurs.
Medical and health research
You can analyze patient survival time, time from treatment to disease recurrence, the time until a particular treatment outcome occurs, and so on.
Marketing and customer analytics
You can analyze the time from sign-up to cancellation, customers' service retention, the time until a repeat purchase, and so on.
HR and organizational research
You can analyze the time from hiring to an employee's departure, the time until promotion to a certain position, and so on.
Manufacturing and reliability analysis
You can analyze the time from installation to failure of machines or equipment, the useful life of a product, the time until a part is replaced, and so on.
Labor economics and social science research
You can analyze the time from job loss to reemployment, the length of a job search, the time until a particular social event occurs, and so on.
Education research
You can analyze the time from enrollment to a student dropping out, the time to earning a degree, the time until leaving an educational program, and so on. In this way, the Kaplan–Meier estimator can be used not only for human survival but for any research dealing with the time until some event occurs.
The Kaplan–Meier estimator shows the time until an event occurs.
The Kaplan–Meier estimator is a nonparametric survival analysis method that estimates the probability that the event of interest has not yet occurred as time passes.
Its most important feature is that it can include censored observations in the analysis. Even for subjects who did not have the event by the end of the study, it can use the information that they were observed event-free up to that time.
From Kaplan–Meier results, you can see the survival probability at each time, the survival curve, the median survival time, and more. You can also compare the survival curves of several groups to see how the time until the event differs.
However, a difference between groups seen in the survival curves does not directly imply a causal relationship. Results should also be interpreted with the nature of the censoring, the number at risk, and the confidence intervals in mind. Be especially careful with the later part of the survival curve, where few observations remain and estimates can become unstable.
The key to the Kaplan–Meier estimator is not simply calculating the proportion of events, but estimating how the probability of remaining event-free changes over time while accounting for censoring.