Run Survival Analysis
Survival Analysis

How to Perform Survival Analysis in Medical Research: Kaplan-Meier Explained

- 14 min read ... June 2025 Updated June 2025
S
StatClinic Editorial Team Statistical content for medical researchers and clinicians
When you study how long patients survive after a cancer diagnosis, how many months elapse before a drug loses effectiveness, or how quickly patients are readmitted after discharge, you are dealing with time-to-event data and this requires a completely different analytical approach from the t-test or chi-square. Kaplan-Meier survival analysis is the standard tool for visualizing and comparing time-to-event outcomes in medicine. This guide explains every component you need to understand, report, and interpret survival analysis correctly in clinical research.

What Is Survival Analysis?

Survival analysis is a branch of statistics that models the time until a specified event occurs. Despite the clinical name, the "event" does not need to be death it can be disease recurrence, hospital readmission, treatment failure, first seizure, or any other binary outcome that occurs at a point in time during follow-up.

The defining characteristic of survival data is that the event may not happen to every subject before the study ends. Some patients are still alive, still in remission, or still event-free when the observation window closes. This creates a fundamental analytical problem: you cannot simply average times-to-event across all patients, because you do not know the final times for subjects who have not yet experienced the event. Standard parametric tests the t-test, ANOVA, or even linear regression have no mechanism to account for this reality, which is why they cannot validly analyze survival outcomes.

1958
Year Kaplan and Meier published the estimator in JASA one of the most cited papers in all of statistics
Top 3
KM is among the three most commonly used statistical methods in clinical oncology publications
Non-parametric
KM makes no assumption about the shape of the underlying survival distribution data speaks for itself

When to Use Survival Analysis

Use survival analysis whenever your research question involves time-to-event data and any of the following conditions apply:

Common applications in medical research include: overall survival (OS) in oncology trials, disease-free survival (DFS) after surgical resection, progression-free survival (PFS) in chemotherapy studies, time to hospital readmission, time to treatment response, and time to first cardiovascular event in cardiology cohort studies.

Why you cannot use a t-test on survival data If 40% of your subjects have not experienced the event by the end of follow-up, their event times are unknown. Using a t-test requires knowing all values. Excluding censored subjects introduces selection bias (those who survive longer are preferentially excluded). Treating the last follow-up date as the event date for censored subjects overestimates events and underestimates survival. Survival analysis is the only valid approach for this data type.

The Kaplan-Meier Estimator: How It Works

The Kaplan-Meier (KM) estimator, introduced by Edward Kaplan and Paul Meier in 1958, is a non-parametric method that estimates the survival function S(t) the probability that a subject survives beyond time t directly from the observed data, without assuming any particular distribution (exponential, Weibull, log-normal, etc.).

The KM Formula

At each time point t where at least one event occurs, the KM estimator multiplies the conditional probabilities of surviving each successive interval:

S(t) = t t (n d) / n
Where n = number of subjects at risk just before time t  |  d = number of events at time t

The result is a step function a staircase that drops at each time point where an event (not a censoring) occurs. Between events, the curve is perfectly flat. The horizontal axis represents time (days, months, or years); the vertical axis represents the estimated probability of surviving (or remaining event-free) to that point.

What the Kaplan-Meier Curve Looks Like

The chart below shows two typical KM curves from a hypothetical stage III non-small cell lung cancer (NSCLC) trial comparing immunotherapy plus chemotherapy (treatment group) against chemotherapy alone (control group). Each downward step represents one or more deaths at that time point. The vertical tick marks () on the curve indicate censored observations patients who left the study before experiencing the event.

Kaplan-Meier Overall Survival Curves Stage III NSCLC (Hypothetical)
15 mo 28 mo Survival Probability 1.0 0.8 0.6 0.5 0.2 0.0 0 6 12 18 24 30 36 Time (months) Log-rank p < 0.001 HR = 0.58 (95% CI 0.470.72)
Immunotherapy + Chemo (Median OS: 28 months)
Chemotherapy alone (Median OS: 15 months)

Understanding Censored Data

Censoring is one of the most important and most misunderstood concepts in survival analysis. A subject is censored when their follow-up ends before the event of interest occurs, and you therefore do not know when (or whether) they would have experienced the event.

Types of Censoring

1

Right censoring (most common in clinical trials)

The event has not yet occurred when observation ends. The subject's true event time is somewhere to the right of the last known contact date. Examples: the study ends on a fixed calendar date and the patient is still alive; the patient is lost to follow-up at month 18; the patient withdraws consent.

2

Left censoring

The event is known to have occurred before a certain time, but the exact time is unknown. Example: a patient has an HIV infection of unknown duration at enrollment they were infected before study entry but the date is unknown. Less common in clinical trials.

3

Interval censoring

The event is known to have occurred between two observation time points, but the exact time within that interval is unknown. Example: a prostate cancer patient has PSA measured every 6 months recurrence occurred sometime between month 18 and month 24 visits.

Censoring Is Not Missing Data

This is perhaps the single most important conceptual point for new researchers: censoring is informative data, not missing data. A censored observation tells you definitively that the subject survived at least until their last known contact date. This information is incorporated into the KM calculation by keeping the subject in the "at-risk" group up until their censoring time, then removing them from subsequent calculations contributing their known survival time to the analysis without assuming they experienced the event.

What happens if you mishandle censored observations If you exclude censored subjects entirely, you remove patients who tended to survive longer (since they had not yet experienced the event), creating a systematic bias toward shorter survival estimates. If you treat censoring time as the event time, you artificially inflate event counts and underestimate true survival. Both errors invalidate your results and in a published trial constitute a serious methodological flaw.

The Non-Informative Censoring Assumption

The Kaplan-Meier method assumes that censoring is non-informative meaning that subjects who are censored have the same underlying survival prospects as those who remain under observation. If patients are lost to follow-up specifically because they are healthier and chose to stop treatment (or conversely, because they died unreported), the censoring mechanism is informative and violates this assumption. Sensitivity analyses, such as worst-case or best-case scenarios for censored outcomes, should be reported when this assumption is uncertain.

Median Survival Time

The median survival time is the point at which the Kaplan-Meier curve crosses the 0.5 probability line the time by which exactly half the subjects have experienced the event. It is the standard summary statistic for survival data and should be the default value reported in clinical publications.

Why Median, Not Mean?

Survival time distributions are almost universally right-skewed: a small number of long-term survivors can dramatically inflate the arithmetic mean, making it an unrepresentative and unreliable summary measure. In studies where the event is death, a handful of patients who survive for decades can pull the mean survival far above what most patients actually experience. The median is resistant to this distortion and is always interpretable as the time at which 50% of your cohort has experienced the event.

Additionally, the mean overall survival cannot even be calculated unless all subjects have experienced the event by the end of follow-up. In most clinical trials with reasonable follow-up periods, a substantial proportion of patients are still alive, making the mean incalculable. The median only requires that the curve crosses 0.5 which occurs as long as at least 50% of subjects eventually experience the event.

Worked Example Reading Median Survival from a KM Curve

A phase III NSCLC trial enrolls 420 patients: 210 receiving pembrolizumab + carboplatin and 210 receiving carboplatin + paclitaxel alone. After 36 months of follow-up, the KM analysis shows:

  • Immunotherapy group: the curve crosses 0.5 at month 28.4 median OS = 28.4 months (95% CI: 24.132.7)
  • Chemotherapy group: the curve crosses 0.5 at month 14.9 median OS = 14.9 months (95% CI: 12.317.5)

The 95% CI is calculated using the Brookmeyer-Crowley method and reflects the precision of the median estimate. The wider the CI, the fewer events contributed to that part of the curve.

Manuscript reporting: "Median overall survival was 28.4 months (95% CI 24.132.7) in the immunotherapy group versus 14.9 months (95% CI 12.317.5) in the chemotherapy group."
When the median cannot be estimated If more than 50% of subjects are still event-free at the end of follow-up, the KM curve never crosses the 0.5 line and the median survival is undefined. This is a good clinical outcome it means most patients survived the follow-up period. In this situation, report the proportion surviving at specific landmark times (e.g., 1-year OS = 87%, 2-year OS = 74%) instead of the median, and state that the median was not reached (NR).

The Log-Rank Test

The KM curve tells you what the survival pattern looks like in each group. The log-rank test (also called the Mantel-Cox test) tells you whether the observed differences between groups are statistically significant i.e., whether they are unlikely to have arisen by chance under the null hypothesis that all groups have identical survival distributions.

How the Log-Rank Test Works

At each time point where an event occurs, the log-rank test calculates the observed number of events (O) in each group and compares it to the expected number of events (E) under the null hypothesis of equal survival. The expected count in each group is proportional to how many subjects were at risk in that group at that particular time. The test statistic combines these observed-minus-expected discrepancies across all event times:

2 = ((O E))2 / (E)
Follows a chi-square distribution with k 1 degrees of freedom (k = number of groups)

The resulting p-value is compared to the pre-specified alpha level (usually 0.05) to determine statistical significance. A log-rank p-value below 0.05 provides evidence that the survival distributions differ between groups.

The Proportional Hazards Assumption

The log-rank test is most powerful when the hazard ratio between groups is constant over time the proportional hazards (PH) assumption. Intuitively, this means the survival curves should not cross and the relative risk of the event should remain the same early and late in follow-up. The PH assumption is satisfied when the KM curves separate cleanly and maintain a roughly consistent distance throughout follow-up.

When survival curves cross, or when one treatment has an early benefit that disappears over time (as seen with some immunotherapies), the log-rank test can produce misleadingly high p-values and miss a real treatment effect. In these situations, the weighted log-rank test (Fleming-Harrington with adjustable weights) or restricted mean survival time (RMST) are better alternatives.

Stratified Log-Rank Test

When important prognostic variables exist (ECOG performance status, disease stage, center in a multicenter trial), the stratified log-rank test controls for these variables by performing the observed-vs-expected comparison separately within each stratum and pooling the results. This is analogous to adjusted analysis in linear regression and is often specified in advance in the statistical analysis plan of a randomized controlled trial.

Log-rank vs Cox regression: which to use? The log-rank test gives you a p-value for comparing two or more survival curves without adjustment. Cox proportional hazards regression goes further it estimates the hazard ratio with a confidence interval and allows you to simultaneously adjust for age, stage, comorbidities, and other confounders. In a randomized trial with balanced groups, the log-rank p-value is sufficient for the primary analysis. In an observational study with confounding, Cox regression is essential for a valid estimate of the treatment or exposure effect.

Oncology Examples: Reading Survival Analysis in Practice

Survival analysis is the backbone of oncology clinical trial reporting. Understanding how to read and critically appraise a published KM curve is an essential skill for any clinician or medical researcher working in cancer medicine.

Example 1: Immunotherapy vs Chemotherapy in Advanced NSCLC

Clinical Scenario

A phase III randomized controlled trial compares pembrolizumab plus platinum-based chemotherapy (n=210) versus chemotherapy alone (n=210) in treatment-naive stage IV NSCLC patients with PD-L1 TPS 1%.

Primary endpoint: Overall survival (OS) defined as time from randomization to death from any cause.

KM findings: At 36 months of follow-up, 68 events had occurred in the immunotherapy group versus 112 in the chemotherapy group. Median OS was 28.4 months (95% CI 24.132.7) versus 14.9 months (12.317.5). The log-rank test yielded p < 0.001. Cox regression gave HR = 0.58 (95% CI 0.470.72), indicating a 42% reduction in the hazard of death with immunotherapy.

Interpretation: Patients treated with pembrolizumab plus chemotherapy had significantly longer overall survival. The survival benefit was consistent across all pre-specified subgroups (age, sex, histology, smoking status), with no statistically significant interaction detected.

Example 2: Disease-Free Survival in Early Breast Cancer

Clinical Scenario

A multicenter retrospective cohort study compares 5-year disease-free survival (DFS) in 860 women with stage II HER2-positive breast cancer treated with: (A) trastuzumab + chemotherapy (n=430) versus (B) chemotherapy alone (n=430). DFS is defined as time from surgery to local or distant recurrence, contralateral breast cancer, or death from any cause whichever occurs first.

KM findings: 5-year DFS was 82.4% (95% CI 78.186.7%) in group A versus 63.2% (95% CI 58.368.1%) in group B. Median DFS was not reached in the trastuzumab group (50%+ were still event-free at 60 months) versus 51.3 months (95% CI 46.855.8) in the chemotherapy group. Log-rank p < 0.001; HR = 0.51 (95% CI 0.400.65).

Note on "not reached": Because more than 50% of trastuzumab-treated patients remained disease-free at 5 years, the median DFS could not be estimated from the KM curve. This is reported as "median DFS not reached (NR)" and is itself a favorable clinical finding. Landmark survival at 5 years is the appropriate summary statistic.

Example 3: Time to Biochemical Recurrence in Prostate Cancer

Clinical Scenario

A single-center cohort of 312 patients with localized prostate cancer receiving radical prostatectomy are followed for biochemical recurrence (BCR), defined as two consecutive PSA values 0.2 ng/mL. Patients are stratified by Gleason score: Gleason 6 (n=124), Gleason 7 (n=118), and Gleason 810 (n=70).

KM findings: 5-year BCR-free survival was 91.2% for Gleason 6, 74.6% for Gleason 7, and 49.3% for Gleason 810. The stratified log-rank test was highly significant (p < 0.001 with 2 degrees of freedom), indicating that Gleason score significantly predicts time to biochemical recurrence.

This three-group comparison requires a chi-square statistic with df = k 1 = 2. The significant global p-value indicates that at least two groups differ, but pairwise post-hoc log-rank tests (with Bonferroni correction, +/- = 0.05/3 = 0.017) are required to identify which specific Gleason score groups are distinguishable.

Interpreting Kaplan-Meier Curves: What to Look For

Reading a KM curve critically requires examining several features beyond the p-value alone.

The Number-at-Risk Table

Every published KM figure should include a number-at-risk table below the x-axis showing how many subjects remain under observation at each time point. As time progresses, this number decreases due to events and censorings. When few subjects remain at risk (typically fewer than 1015 per group), the KM curve becomes highly unstable each additional event causes a disproportionately large downward jump. The number-at-risk table allows readers to judge which parts of the curve are reliably estimated and which represent sparse data.

Confidence Interval Width

The shaded confidence interval bands around each KM curve (usually representing the 95% CI using Greenwood's formula) widen progressively toward the right tail of the curve. This widening visually communicates increasing statistical uncertainty as fewer subjects remain at risk. Two curves whose confidence intervals substantially overlap in a region of follow-up suggest that the survival difference in that region is not reliably estimated, regardless of the overall p-value.

Crossing Survival Curves

When two KM curves cross, the treatment effect is not constant over time there may be an initial benefit with one treatment and a late benefit with the other. Crossing curves are common with immunotherapies, which may initially appear to have worse early outcomes (immune-related adverse events, early progression) before demonstrating durable long-term benefit. As discussed above, crossing curves violate the proportional hazards assumption and make the log-rank test unreliable. Never apply a log-rank test uncritically when curves cross report restricted mean survival time (RMST) instead.

Clinical vs Statistical Significance

A statistically significant log-rank p-value in a large trial can correspond to a survival difference of a few weeks not clinically meaningful. Conversely, a borderline p-value in a small trial may correspond to a large absolute difference in median survival with wide confidence intervals. Always assess the absolute difference in median survival, the hazard ratio, and whether the effect size meets established thresholds for clinical significance in the relevant disease area before drawing conclusions.

Common Mistakes Researchers Make in Survival Analysis

Mistake 1: Using a t-test or Mann-Whitney to compare survival times

Some researchers apply a t-test directly to survival times (months to event), treating them like any other continuous outcome. This fails on two counts: it cannot account for censored observations (which are excluded, biasing the comparison), and survival times are rarely normally distributed, violating the t-test's core assumption.

Fix: Always use the log-rank test for group comparisons and the KM estimator for visualization of survival data. For adjusted comparisons, use Cox proportional hazards regression.

Mistake 2: Treating censored observations as events

Assigning the censoring date as the event date "they left the study, so I'll count that as the time of death" dramatically underestimates survival and inflates event counts. This error is particularly serious when censoring is common or when the censored group has systematically different characteristics from those who experienced the event.

Fix: Code censored observations correctly (event indicator = 0, time = last known alive contact). Let the KM estimator handle these appropriately.

Mistake 3: Omitting the number-at-risk table

Publishing a KM curve without a number-at-risk table beneath it makes it impossible for readers to judge the reliability of the right-tail estimate. Most major oncology journals (JCO, Lancet Oncology, NEJM) require this table as standard. Without it, a curve showing "70% survival at 5 years" could be based on 200 patients or on 3 patients readers cannot tell.

Fix: Include a number-at-risk table at regular time intervals (e.g., every 6 or 12 months) below the x-axis of every KM figure. Most statistical software (R survminer, SPSS, SAS) generates this automatically.

Mistake 4: Truncating the curve when few subjects remain at risk

Researchers sometimes extend the KM curve all the way to the last observed event, even when only 12 subjects remain at risk. This gives the false impression of a reliable long-term survival estimate. The final few steps of the curve each representing a survival probability of 1/(small number) are extremely imprecise and can be visually dramatic without being informative.

Fix: Truncate the KM curve at a point where fewer than 10 subjects remain at risk per group, and state this threshold in the figure legend. Some guidelines recommend truncating at 5% of the original sample size.

Mistake 5: Applying the log-rank test when curves cross

The log-rank test assumes proportional hazards (constant hazard ratio over time). When two survival curves cross one group initially better, the other group better later this assumption is violated. The log-rank test in this setting is underpowered, gives a p-value biased toward the null, and may miss a real but time-varying effect.

Fix: Test the proportional hazards assumption (e.g., Schoenfeld residuals, log-log plot) before interpreting the log-rank test. If hazards are non-proportional, report restricted mean survival time (RMST) at a clinically relevant time horizon instead.

Mistake 6: Performing landmark analysis post hoc

A "landmark analysis" excludes subjects who experienced the event before a specified time point (the "landmark") and examines subsequent survival from that point forward. This is legitimate when pre-specified, but performing it post hoc especially after examining the data introduces selection bias because it removes early events from one or both groups in a non-random way.

Fix: Pre-specify all landmark analyses in the statistical analysis plan or protocol before data collection. If applied post hoc, clearly label the analysis as exploratory and interpret the results cautiously.

Frequently Asked Questions

What is the difference between Kaplan-Meier and Cox regression?+
Kaplan-Meier is a descriptive, non-parametric method that estimates and plots the survival function directly from observed data. It does not control for confounders it shows you what survival looked like in each group as observed. Cox proportional hazards regression is an analytical model that estimates the effect of one or more covariates (age, stage, treatment, comorbidities) on the hazard rate while adjusting for all other variables simultaneously, producing a hazard ratio with a confidence interval.

Use KM for visualization and unadjusted comparisons; use Cox regression when you need to control for confounding variables, estimate an adjusted hazard ratio, or identify independent prognostic factors.
Can I use the log-rank test for more than two groups?+
Yes. The log-rank test generalizes to three or more groups using a chi-square statistic with k 1 degrees of freedom (where k = number of groups). A significant overall test indicates that at least one group differs from the others, but does not identify which specific groups differ.

For pairwise comparisons, perform post-hoc log-rank tests with a Bonferroni correction (alpha / number of pairs) to control the family-wise error rate. For example, with 3 groups (3 pairwise comparisons), use a threshold of +/- = 0.05/3 = 0.017 for each pairwise test.
What happens if my two Kaplan-Meier curves cross?+
Crossing KM curves indicate non-proportional hazards one treatment may be better early and the other better later in follow-up. This commonly occurs with immunotherapy (delayed response, durable benefit) and with some targeted therapies that achieve initial response but develop resistance over time.

Crossing curves violate the core assumption of the log-rank test, which assumes a constant hazard ratio over the entire follow-up period. When curves cross, the log-rank test is underpowered and may produce misleadingly high p-values. Better alternatives include: the weighted log-rank test (Fleming-Harrington weights), restricted mean survival time (RMST), or fitting a parametric survival model with time-varying hazard ratios.
How do I report Kaplan-Meier results in a medical paper?+
A complete survival analysis report should include:

1. Median survival time with 95% CI (Brookmeyer-Crowley method) for each group
2. Log-rank test p-value
3. Hazard ratio and 95% CI from Cox regression (adjusted if confounders exist)
4. KM figure with confidence interval shading and number-at-risk table
5. Total follow-up time and median follow-up duration

Example sentence: "Median overall survival was 28.4 months (95% CI 24.132.7) in the immunotherapy group versus 14.9 months (95% CI 12.317.5) in the chemotherapy group (log-rank p < 0.001; HR 0.58, 95% CI 0.470.72)."
What is the minimum sample size for survival analysis?+
Survival analysis (particularly the log-rank test) requires a sufficient number of observed events not just enrolled patients. A widely cited rule of thumb is at least 1015 events per group for reliable KM estimation, and at least 10 events per covariate in Cox regression.

For formal sample size calculation, specify: expected event rate in each group, median survival in each group, desired power (typically 8090%), alpha level (usually 0.05, two-sided), and expected censoring rate. Statistical software (R's survminimax, PASS, or the StatClinic sample size calculator) can compute the required number of events and corresponding sample size for the primary endpoint.
Can survival analysis be used for outcomes other than death?+
Absolutely despite the name, survival analysis applies to any time-to-event outcome where the event may not occur during the study period. Common medical applications include:

  • Time to disease recurrence after surgery or chemotherapy
  • Time to hospital readmission after discharge
  • Time to treatment response or first complete remission
  • Time to first seizure in patients with epilepsy risk
  • Time to pregnancy in fertility research
  • Time to surgical complication after elective procedures
  • Time to ICU discharge in critical care research
The statistical methodology is identical regardless of the event type.
How do I handle tied event times in Kaplan-Meier analysis?+
Ties occur when multiple subjects experience the event at the exact same recorded time common when follow-up is recorded in whole months rather than exact dates. The Kaplan-Meier estimator handles ties by applying the event probability at the tied time to all tied subjects simultaneously, with the convention that censoring at a time point is processed after events at that time.

For the log-rank test, the Peto-Peto (Breslow) method handles ties. In Cox regression, the Efron approximation is preferred when ties are common, as it is more accurate than the Breslow approximation in that setting. Using exact event dates whenever possible reduces the frequency of ties and eliminates the need for tie-breaking assumptions.

Run Kaplan-Meier Survival Analysis Free

StatClinic's survival analysis tool generates KM curves, log-rank test results, median survival with 95% CI, and a number-at-risk table automatically. Paste your data and get publication-ready output in seconds no software to install, no login required.

Open Kaplan-Meier Tool