Tutorials › Biostatistics › Log-Rank Test for Comparing Survival Curves

Survival Analysis

Log-Rank Test for Comparing Survival Curves

A practical guide to the log-rank test for comparing time-to-event distributions, including the null hypothesis, observed and expected events, the test statistic, a complete clinical example, interpretation, assumptions, stratification, and common mistakes.

Intermediate 14 min read

What You'll Learn

  • Why the log-rank test is used for time-to-event outcomes
  • How observed and expected event counts are constructed
  • How the log-rank statistic and p-value are calculated
  • How censoring is incorporated into the comparison
  • How to interpret a significant and nonsignificant log-rank test
  • When stratified log-rank testing and Cox regression are preferable

Introduction

Clinical studies frequently compare treatments using a time-to-event endpoint. Examples include overall survival, progression-free survival, time to relapse, time to treatment failure, and time to cardiovascular hospitalization.

These endpoints differ from ordinary continuous or binary outcomes because not every patient necessarily experiences the event during follow-up. A patient may complete the study without an event, withdraw, or remain event-free when the database is locked. Such an observation is censored.

The Kaplan–Meier estimator is commonly used to describe the survival experience within each treatment group. The natural next question is whether the observed survival curves provide statistical evidence that the groups differ.

Key idea: The log-rank test compares the survival experience of two or more groups by comparing the number of events actually observed in each group with the number that would be expected if the groups had the same underlying survival distribution.

The Clinical Question

Suppose a randomized clinical trial compares an experimental treatment with control and follows patients until death, disease progression, or censoring. Let \(S_1(t)\) and \(S_2(t)\) denote the survival functions for the two groups. The log-rank test evaluates the null hypothesis:

\[ H_0:S_1(t)=S_2(t)\quad\text{for all }t \]

against the alternative that the survival distributions differ.

In a two-group comparison, the test is typically presented as a two-sided test. The direction of the difference is then examined using the Kaplan–Meier curves and other effect estimates such as a hazard ratio.

Important distinction: A significant log-rank test tells you that the survival distributions differ. It does not by itself tell you the magnitude of the treatment effect, the clinical importance of the difference, or the hazard ratio.

Why Ordinary Tests Are Not Enough

A standard comparison of mean survival time is often inappropriate because survival data are usually censored and may be highly skewed.

For example, suppose one treatment group has several patients who are still alive at the end of follow-up. Their exact survival times are unknown. We know only that their survival exceeds their observed follow-up time.

Simply treating those patients as if their observed follow-up time were their true survival time would bias the analysis.

The log-rank test avoids this problem by using the information available at each observed event time while properly accounting for patients who are still at risk and those who have already been censored.

Relationship to the Kaplan–Meier Curve

The Kaplan–Meier estimator describes survival within each group:

\[ \widehat S(t) = \prod_{t_i\le t} \left( 1-\frac{d_i}{n_i} \right) \]

where \(n_i\) is the number at risk immediately before event time \(t_i\), and \(d_i\) is the number of events at that time.

The log-rank test uses a related risk-set framework, but instead of estimating a survival probability, it asks whether the pattern of events differs between groups.

1
Kaplan–Meier: estimate and display survival over time.
2
Log-rank test: formally compare the survival distributions.
3
Cox model: estimate a hazard ratio and adjust for covariates when appropriate.

The Basic Log-Rank Idea

At every time at which an event occurs, we know how many patients are still at risk in each treatment group. Suppose at one event time:

Quantity Treatment Control Total
Patients at risk 40 60 100
Observed events 2 3 5

If the two groups have identical survival distributions, the five events should be distributed approximately in proportion to the numbers at risk.

The expected number of events in the treatment group is therefore:

\[ E_1 = 5\left(\frac{40}{100}\right) = 2 \]

The control group would have:

\[ E_2 = 5\left(\frac{60}{100}\right) = 3 \]

In this particular risk set, the observed and expected event counts are identical.

The log-rank test repeats this calculation across all event times and combines the differences between observed and expected events.

Observed and Expected Events

For a two-group comparison, define:

  • \(O_1\) = total observed events in Group 1
  • \(E_1\) = total expected events in Group 1 under the null hypothesis
  • \(O_2\) = total observed events in Group 2
  • \(E_2\) = total expected events in Group 2

At event time \(t_j\), let:

  • \(n_{1j}\) = Group 1 patients at risk
  • \(n_{2j}\) = Group 2 patients at risk
  • \(n_j=n_{1j}+n_{2j}\) = total patients at risk
  • \(d_j\) = total events at \(t_j\)

The expected number of Group 1 events at that time is:

\[ E_{1j} = d_j\frac{n_{1j}}{n_j} \]

The expected total for Group 1 is obtained by summing over all event times:

\[ E_1 = \sum_j d_j\frac{n_{1j}}{n_j} \]

The same calculation applies to Group 2.

Interpretation: If the treatment has better survival, it will tend to experience fewer events than expected. If it has worse survival, it will tend to experience more events than expected.

A Small Worked Risk-Set Example

Suppose a trial has the following risk set at a particular event time.

Quantity Experimental Control
At risk 50 50
Events at this time 1 4
Total at risk 100
Total events 5

Under the null hypothesis, the expected number of experimental events is:

\[ E_{1j} = 5\left(\frac{50}{100}\right) = 2.5 \]

The observed number is only 1. Therefore, the experimental group has:

\[ O_{1j}-E_{1j} = 1-2.5 = -1.5 \]

A negative difference is consistent with fewer events than expected in the experimental group.

The log-rank test accumulates this type of discrepancy over all event times. One isolated event time is not enough to establish a treatment effect.

The Log-Rank Test Statistic

For two groups, the basic log-rank statistic can be expressed as:

\[ Z = \frac{O_1-E_1} {\sqrt{\operatorname{Var}(O_1-E_1)}} \]

Under the null hypothesis and with a sufficiently large number of events, the statistic is approximately standard normal.

An equivalent chi-square formulation is:

\[ \chi^2 = \frac{(O_1-E_1)^2} {\operatorname{Var}(O_1-E_1)} \]

For a two-group comparison, this statistic has approximately a chi-square distribution with:

\[ df=1 \]

The p-value is obtained by comparing the observed statistic with the corresponding reference distribution.

Why does the sign disappear? The chi-square statistic squares the difference between observed and expected events. Consequently, it tests whether the groups differ but does not preserve the direction of the effect. The direction must be determined from the observed-versus-expected counts, Kaplan–Meier curves, and/or the estimated hazard ratio.

Variance of the Observed-minus-Expected Difference

For a simple two-group setting with one event at each event time, the variance contribution can be written approximately as:

\[ V_j = \frac{ n_{1j}n_{2j}d_j(n_j-d_j) }{ n_j^2(n_j-1) } \]

The total variance is obtained by summing the contributions over event times:

\[ V = \sum_j V_j \]

The log-rank statistic can then be written as:

\[ \chi^2 = \frac{(O_1-E_1)^2}{V} \]

In practice, statistical software performs these calculations automatically, including appropriate handling of tied event times.

Complete Clinical Example

Consider a randomized Phase III oncology trial comparing an experimental treatment with control. The primary time-to-event endpoint is progression-free survival. The analysis includes:

Parameter Value
Experimental group 100 patients
Control group 100 patients
Total sample size 200 patients
Primary endpoint Progression-free survival
Analysis Kaplan–Meier + log-rank test
Hypothesis Two-sided

Suppose that by database lock:

Outcome Experimental Control Total
Patients 100 100 200
Observed progressions/deaths 60 75 135
Censored 40 25 65

The experimental group has fewer events than the control group. However, comparing the raw event counts alone is not sufficient.

A patient who remains event-free for a long period contributes information before censoring. The log-rank test therefore evaluates events in relation to the risk sets at each event time.

Step 1: Construct the Risk Sets

Imagine that the event history produces several distinct event times. At each event time, patients who have already experienced the event or have already been censored are no longer included in the risk set.

For illustration, consider three representative event times.

Event Time Experimental at Risk Control at Risk Total Events
\(t_1\) 100 100 1
\(t_2\) 94 97 1
\(t_3\) 88 94 1

At \(t_1\), for example, the expected number of experimental events is:

\[ E_{1,1} = 1\left(\frac{100}{200}\right) = 0.50 \]

If the event occurred in the experimental group, its contribution to \(O-E\) would be:

\[ 1-0.50=0.50 \]

If the event occurred in the control group, the contribution would instead be:

\[ 0-0.50=-0.50 \]

The actual test uses the entire sequence of event times rather than only these three illustrative times.

Step 2: Sum Observed and Expected Events

Suppose the complete event-time calculation gives:

Quantity Experimental Control
Observed events \(O\) 60 75
Expected events \(E\) 67.5 67.5
Observed − Expected -7.5 +7.5

The experimental group experienced fewer events than expected under the null hypothesis.

Clinical interpretation: The direction of \(O-E\) suggests that the experimental treatment may be associated with better progression-free survival because fewer progression or death events occurred than would be expected if the survival distributions were identical.

Step 3: Calculate the Test Statistic

Suppose the variance of the observed-minus-expected difference is:

\[ V=16.8 \]

The log-rank chi-square statistic is then:

\[ \chi^2 = \frac{(-7.5)^2}{16.8} \]

which gives approximately:

\[ \chi^2\approx3.35 \]

With one degree of freedom, this corresponds to a two-sided p-value of approximately:

\[ p\approx0.067 \]

This illustrative result would not meet the conventional 0.05 significance threshold.

Interpretation: Although the experimental group experienced fewer events than expected, the illustrative log-rank test does not provide sufficiently strong statistical evidence to reject the null hypothesis at the 5% level.

What a Significant Log-Rank Test Means

Suppose instead that the analysis produced:

\[ p=0.018 \]

A conventional interpretation would be:

There is statistically significant evidence that the survival distributions differ between the treatment groups.

If the experimental group also has fewer observed events than expected and its Kaplan–Meier curve lies above the control curve, the result would be consistent with better survival under the experimental treatment.

However, the log-rank p-value should not be interpreted as a measure of effect size.

What the Log-Rank Test Does Not Tell You

A p-value does not tell you:

  • How large the treatment effect is
  • Whether the effect is clinically meaningful
  • The median survival time by itself
  • The hazard ratio
  • Whether the proportional hazards assumption is satisfied
  • Whether the treatment is beneficial at every point in time

For these questions, the log-rank test should be considered alongside the Kaplan–Meier estimates, confidence intervals, and an appropriate effect measure such as a hazard ratio.

Log-Rank Test and the Hazard Ratio

The log-rank test and Cox proportional hazards regression are closely related, but they answer somewhat different questions.

Method Primary role
Kaplan–Meier Describe survival over time
Log-rank test Test whether survival distributions differ
Cox regression Estimate hazard ratios and adjust for covariates

A typical clinical trial presentation therefore includes all three components.

1
Plot Kaplan–Meier curves for each treatment group.
2
Report numbers at risk and important survival estimates.
3
Perform the prespecified log-rank comparison.
4
Estimate the hazard ratio and confidence interval using an appropriate model.
5
Interpret statistical evidence together with clinical magnitude and uncertainty.

Why Censoring Matters

Censoring is one of the defining features of survival analysis. Suppose a patient enters a study and remains progression-free for 18 months, but the study ends at that point. We know that the patient's progression time is greater than 18 months, but we do not know the exact progression time.

The patient therefore contributes information to the risk sets for the period during which the patient is known to be event-free.

When the patient is censored, the patient leaves the risk set.

Important: Censoring does not mean that the patient is treated as having experienced the event. It means that the patient's event time is only partially observed.

Assumptions Behind the Log-Rank Test

The log-rank test relies on the validity of the survival-analysis framework, including appropriate handling of censoring.

A particularly important assumption is that censoring is appropriately independent of the future event process, conditional on the information used in the analysis.

In practical terms, informative censoring can bias survival comparisons.

The log-rank test also has an important relationship with the proportional hazards framework.

It is generally most powerful when the groups differ through a reasonably consistent hazard ratio over time.

Key limitation: If survival curves cross substantially, the ordinary log-rank test may have low power or may not summarize the clinically relevant difference well.

Crossing Survival Curves

Consider a situation in which Treatment A has better survival early but worse survival later. The Kaplan–Meier curves may cross.

In that setting, positive and negative contributions to the log-rank statistic can partially cancel.

Consequently, a nonsignificant log-rank test does not necessarily mean that the treatments behave identically throughout follow-up.

If crossing curves are anticipated, investigators should consider whether alternative approaches are more appropriate, such as weighted log-rank tests, restricted mean survival time, or other prespecified estimands.

Weighted Log-Rank Tests

The ordinary log-rank test gives broadly similar weight to event times through the risk-set comparison.

Weighted log-rank tests modify this weighting. Depending on the weighting scheme, more emphasis can be placed on early or late differences.

Situation Potential consideration
Proportional hazards approximately plausible Ordinary log-rank test
Early treatment effect is especially important Consider an appropriate weighted test
Late separation is especially important Consider an appropriate weighted test
Substantial curve crossing Consider RMST or other prespecified alternatives

The choice should be specified before examining treatment differences whenever possible.

Stratified Log-Rank Tests

Randomized trials may contain important stratification factors such as disease stage, geographic region, prior therapy, or baseline risk group.

A stratified log-rank test compares treatment groups while accounting for predefined strata.

Within each stratum, the observed and expected event counts are calculated using the relevant risk sets. The contributions are then combined across strata.

\[ O_1-E_1 = \sum_{s=1}^{S} \left(O_{1s}-E_{1s}\right) \]

where \(s\) indexes the strata.

Practical point: If randomization was stratified and the statistical analysis plan specifies a stratified primary analysis, the primary log-rank comparison should generally reflect that prespecified stratification.

More Than Two Treatment Groups

The log-rank framework can also compare more than two groups. For example, a three-arm trial might compare:

  • Experimental Treatment A
  • Experimental Treatment B
  • Control

The overall test asks whether there is evidence that at least one survival distribution differs from the others.

If the overall test is significant, investigators may perform prespecified pairwise comparisons, with appropriate consideration of multiplicity.

Analysis Question
Overall log-rank test Do any groups differ?
Pairwise log-rank tests Which specific groups differ?
Adjusted pairwise analysis How should multiplicity be controlled?

How Statistical Software Reports the Test

Most statistical software reports the log-rank test directly from the survival data. For example, in R, a typical analysis uses the survival package.

library(survival)

fit <- survdiff(
  Surv(time, status) ~ treatment,
  data = trial_data
)

fit

Here:

  • time contains the observed follow-up time.
  • status indicates whether the event occurred.
  • treatment identifies the treatment group.

The resulting object contains the observed and expected event counts and the log-rank test statistic.

Example in SAS

In SAS, the log-rank test is commonly requested through PROC LIFETEST.

proc lifetest data=trial_data
              plots=survival;
    time time*status(0);
    strata treatment;
run;

The value specified in parentheses identifies the censoring value in this example.

The procedure produces Kaplan–Meier estimates and the corresponding survival-curve comparison tests.

How to Read a Kaplan–Meier + Log-Rank Result

Suppose a clinical trial reports:

Result Experimental Control
Median PFS 14.8 months 10.2 months
Hazard ratio 0.72 (95% CI 0.56–0.93)
Log-rank p-value 0.009

A concise interpretation would be:

The experimental treatment was associated with longer progression-free survival than control, with a statistically significant difference in the survival distributions based on the log-rank test (p=0.009).

The hazard ratio and its confidence interval provide additional information about the magnitude and precision of the treatment effect.

Best practice: Do not report the log-rank p-value without showing or describing the survival curves and without reporting an appropriate effect estimate when the analysis is intended to quantify treatment benefit.

Common Mistakes

  1. Comparing raw event counts. Having fewer events in one group does not automatically establish better survival because group sizes and risk sets change over time.
  2. Ignoring censoring. Censored observations contain partial survival information and should not simply be treated as events or discarded.
  3. Interpreting the p-value as the treatment effect. The log-rank p-value describes statistical evidence against the null hypothesis; it does not quantify the magnitude of benefit.
  4. Assuming a nonsignificant result proves equality. A nonsignificant result means that the analysis did not provide sufficient evidence to reject the null. It does not prove that the survival curves are identical.
  5. Ignoring crossing curves. The ordinary log-rank test may not be the most informative analysis when the survival curves cross substantially.
  6. Using the log-rank test without considering the prespecified analysis. If the trial was randomized with stratification factors or a particular primary estimand, the analysis should follow the statistical analysis plan.
  7. Reporting only the median survival times. Median survival can be unavailable or unstable when substantial censoring occurs before the median is reached.
  8. Forgetting the number-at-risk display. The number of patients contributing information can become small late in follow-up, making the tail of a Kaplan–Meier curve unstable.
  9. Confusing survival probability with hazard. A Kaplan–Meier curve describes survival probability over time, whereas a hazard ratio compares instantaneous event rates under the proportional hazards framework.

A Practical Survival-Curve Analysis Workflow

1
Define the time origin and event endpoint.
2
Define the event and censoring indicators precisely.
3
Construct Kaplan–Meier curves by treatment group.
4
Display numbers at risk beneath the curves.
5
Review the shape of the curves and assess whether substantial crossing is present.
6
Perform the prespecified log-rank test.
7
Examine observed versus expected event counts to understand the direction of the difference.
8
Estimate the treatment effect using an appropriate model or estimand.
9
Report the estimate, confidence interval, and p-value.
10
Interpret statistical significance together with clinical relevance.

What Should Be Reported in a Statistical Analysis Plan?

For a clinical trial using a log-rank test as a primary or important time-to-event analysis, the statistical analysis plan should make the analysis reproducible.

At minimum, specify:

  • Time origin
  • Time-to-event endpoint definition
  • Event definition
  • Censoring rules
  • Analysis population
  • Treatment comparison
  • One-sided or two-sided significance level
  • Unstratified or stratified log-rank test
  • Stratification factors, if applicable
  • Handling of tied event times
  • Kaplan–Meier estimation method
  • Method for estimating treatment effect
  • Confidence interval method
  • Handling of missing or inconsistent dates
  • Rules for follow-up and administrative censoring

Relationship to Sample Size and Power

For time-to-event studies, statistical power is driven strongly by the number of events, not simply by the number of enrolled patients.

This is an important distinction from ordinary fixed-sample continuous outcomes.

A trial may enroll hundreds of patients but have limited power if relatively few events occur. Conversely, a trial with substantial event information may achieve strong power with fewer patients.

Under a proportional hazards framework, a commonly used approximation for the required number of events is related to the expected hazard ratio.

\[ D \approx \frac{ \left(z_{1-\alpha/2}+z_{1-\beta}\right)^2 }{ \left(\log HR\right)^2 \,p(1-p) } \]

where \(D\) is the required number of events and \(p\) is the allocation proportion to one treatment group.

The exact sample-size calculation depends on the design, allocation ratio, accrual pattern, follow-up, censoring, effect size, and other assumptions.

Key concept: For many time-to-event trials, events drive information. Enrollment targets must therefore be translated into expected event counts, taking accrual and follow-up into account.

When the Log-Rank Test Is a Good Choice

The ordinary log-rank test is particularly useful when:

  • The endpoint is time to an event.
  • Censoring is present.
  • There are two or more groups to compare.
  • The survival curves are not expected to cross substantially.
  • A nonparametric comparison of survival distributions is desired.
  • The proportional hazards framework is reasonably appropriate.

When to Consider Other Methods

The log-rank test is not universally optimal. Alternative or complementary analyses may be preferable when:

Situation Possible approach
Need an adjusted treatment effect Cox proportional hazards regression
Important baseline covariates Adjusted survival model
Strongly crossing survival curves RMST or other prespecified alternatives
Nonproportional hazards Time-varying or alternative estimands/models
More emphasis on a particular time period Restricted mean survival or milestone survival

The appropriate method should be determined by the clinical question and estimand rather than selected after seeing which test produces the smallest p-value.

The Most Important Concept

The most important conceptual point is that the log-rank test does not simply compare how many events occurred in each treatment group.

Instead, it repeatedly asks: given the patients who were still at risk at each event time, how many events would we expect in each group if the survival distributions were the same?

The observed-minus-expected differences are then accumulated across the entire follow-up period.

Thus, the analysis naturally incorporates:

  • Different numbers of patients remaining at risk over time
  • Censoring
  • The timing of events
  • The allocation of patients between treatment groups
Bottom line: The log-rank test is a standard nonparametric method for comparing survival distributions between two or more groups. It works by comparing observed and expected event counts across successive risk sets. A significant result provides evidence that the survival distributions differ, but the p-value does not quantify the treatment effect. In clinical trials, the log-rank test should generally be interpreted together with Kaplan–Meier curves, numbers at risk, effect estimates such as hazard ratios or restricted mean survival differences, confidence intervals, and the clinical context.

References

Mantel, N. (1966). Evaluation of survival data and two new rank order statistics arising in its consideration. Cancer Chemotherapy Reports, 50, 163–170.
Peto, R. & Peto, J. (1972). Asymptotically efficient rank invariant test procedures. Journal of the Royal Statistical Society: Series A, 135, 185–207.
Kaplan, E.L. & Meier, P. (1958). Nonparametric estimation from incomplete observations. Journal of the American Statistical Association, 53, 457–481.
Cox, D.R. (1972). Regression models and life-tables. Journal of the Royal Statistical Society: Series B, 34, 187–220.
Fleming, T.R. & Harrington, D.P. (1991). Counting Processes and Survival Analysis. Wiley.

Clinical Trials

See these methods in real clinical trials

See the method applied to published trial results, with the estimates, confidence intervals and interpretation explained.

REVEAL
Independent statistical analysis of the phase 3 REVEAL trial of anacetrapib versus placebo in atherosclerotic cardiovascular disease, including trial design, time-to-event endpoints,…
Phase 3 · n = 30,449
FOURIER
Independent statistical analysis of the FOURIER phase 3 trial of evolocumab versus placebo in subjects with elevated cardiovascular risk and dyslipidemia, including…
Phase 3 · n = 27,564
TEAM
Independent statistical analysis of TEAM, the randomized phase 3 trial comparing exemestane with tamoxifen followed by exemestane in postmenopausal patients with receptor-positive…
Phase 3 · n = 9,779
ALTTO
Independent statistical analysis of the phase 3 ALTTO trial of lapatinib and trastuzumab in breast neoplasms, covering randomized trial design, disease-free survival,…
Phase 3 · n = 8,381
FIDELIO-DKD
An independent statistical analysis of FIDELIO-DKD, the randomized phase 3 trial of finerenone versus placebo in subjects with type 2 diabetes mellitus…
Phase 3 · n = 5,734
HVTN 702
Independent statistical analysis of HVTN 702, a randomized phase 2/3 HIV vaccine prevention trial evaluating ALVAC-HIV and bivalent subtype C gp120/MF59 versus…
Phase 2/3 · n = 5,404
See all 243 trials using log-rank test →