Log-Rank Test Calculator

Compare survival curves between groups.

Examples:

Group 1 (Treatment)

Group 2 (Control)

Enter observed and expected event counts for both groups

Use the log-rank test when you want to compare survival curves between two or more groups. It's the standard hypothesis test for asking whether groups have different survival experiences, accounting for censored observations.

What Is the Log-Rank Test?

The log-rank test (also called Mantel-Cox test) compares survival distributions between groups by comparing observed to expected events at each time point.

Ο‡2=(O1βˆ’E1)2E1+(O2βˆ’E2)2E2\chi^2 = \frac{(O_1 - E_1)^2}{E_1} + \frac{(O_2 - E_2)^2}{E_2}

Or equivalently:

Ο‡2=(O1βˆ’E1)2V\chi^2 = \frac{(O_1 - E_1)^2}{V}

Where:

  • O = observed events
  • E = expected events under null hypothesis
  • V = variance of O - E

How It Works

At each event time:

  1. Count who is at risk in each group
  2. Calculate expected events based on risk proportions
  3. Sum up (observed - expected) across all event times
  4. Compare to chi-square distribution with df = groups - 1

Example Calculation

Two groups followed over time:

TimeAt Risk (A)Events (A)At Risk (B)Events (B)
3201182
6182151
9151132
12132101

At time 3:

  • Total at risk: 20 + 18 = 38
  • Total events: 1 + 2 = 3
  • Expected for A: 3 Γ— (20/38) = 1.58
  • Expected for B: 3 Γ— (18/38) = 1.42

Continue for all time points, then sum:

  • O₁ - E₁ = observed minus expected for group A
  • Calculate variance
  • Test statistic: χ² = (O₁ - E₁)Β² / V

Interpreting Results

p-valueConclusion
p < 0.05Survival curves differ significantly
p β‰₯ 0.05No significant difference detected

The test tells you if curves differ, not how they differ. Always inspect Kaplan-Meier curves.

Assumptions

  1. Independent censoring: Censoring unrelated to survival
  2. Non-informative censoring: Same across groups
  3. Proportional hazards: Hazard ratio constant over time

When Curves Cross

If survival curves cross, the log-rank test may miss the difference or give misleading results. In this case:

  • Use restricted mean survival time (RMST)
  • Weighted log-rank tests
  • Separate analysis by time period

Weighted Log-Rank Tests

Different weights emphasize different parts of the survival curve:

TestWeightsEmphasizes
Log-rank (Mantel-Cox)1All times equally
Wilcoxon (Gehan-Breslow)n at riskEarly events
Tarone-Ware√(n at risk)Compromise
Peto-PetoŜ(t)Moderate weighting

Use Wilcoxon when:

  • Early differences are most important
  • More censoring later
  • You expect early separation of curves

Use log-rank when:

  • No prior expectation about timing
  • Proportional hazards reasonable

More Than Two Groups

For k groups: Ο‡2=βˆ‘i=1k(Oiβˆ’Ei)2Vi\chi^2 = \sum_{i=1}^{k} \frac{(O_i - E_i)^2}{V_i}

With df = k - 1.

Post-hoc comparisons: If overall test is significant, compare pairs with Bonferroni correction.

Stratified Log-Rank Test

When you want to control for a confounder:

  1. Perform log-rank within each stratum
  2. Combine test statistics across strata

This tests the treatment effect while controlling for the stratifying variable (e.g., age group, disease stage).

Trend Test

For ordered groups (e.g., dose levels):

Ο‡trend2=[βˆ‘scoreiΓ—(Oiβˆ’Ei)]2Var\chi^2_{trend} = \frac{[\sum score_i \times (O_i - E_i)]^2}{Var}

Tests for linear trend in survival across groups.

Sample Size and Power

Number of events needed:

E=4(zα+zβ)2(ln⁑HR)2E = \frac{4(z_\alpha + z_\beta)^2}{(\ln HR)^2}

Where HR is the expected hazard ratio.

HREvents needed (80% power, Ξ±=0.05)
0.552
0.696
0.7186
0.8422

Events, not sample size, drive power.

Effect Size from Log-Rank

The log-rank test doesn't directly give effect size. To get hazard ratio:

HRβ‰ˆO1/E1O2/E2HR \approx \frac{O_1/E_1}{O_2/E_2}

Or more precisely, use Cox regression.

Median Survival Comparison

Report alongside the test:

  • Median survival for each group
  • Confidence intervals for medians
  • Survival rates at clinically relevant times (1-year, 5-year)

Reporting Guidelines

Standard format: "Survival was significantly better in the treatment group compared to control (median survival: 24 vs. 18 months; log-rank χ² = 8.4, df = 1, p = 0.004)."

Include:

  • Kaplan-Meier curves with numbers at risk
  • Log-rank statistic and p-value
  • Median survival with 95% CI
  • Hazard ratio (from Cox regression)

Common Mistakes

Ignoring Curve Shape

Two curves can have the same log-rank p-value but very different clinical implications. Always plot the curves.

Over-interpreting Non-Significance

A non-significant log-rank test means you failed to detect a difference, not that there is no difference. Check power.

Using with Crossed Curves

Log-rank assumes proportional hazards. If curves cross, consider alternatives.

Forgetting Censoring Pattern

Heavy, differential censoring can bias results. Report censoring rates by group.

Log-Rank vs. Hazard Ratio

Log-Rank TestHazard Ratio
Hypothesis testEffect size
Overall comparisonMagnitude of difference
NonparametricFrom Cox regression
Answers: Different?Answers: How much?

Use both together for complete picture.

Applications

Oncology

Comparing survival between treatment arms in clinical trials.

Cardiology

Time to heart attack by risk factor group.

Reliability

Comparing time to failure between product versions.

Social Science

Duration until event (recidivism, employment termination).

Historical Context

Nathan Mantel and W. Haenszel developed the test in 1959 for combining case-control studies. David Cox adapted it for survival data. Richard Peto and colleagues popularized it in cancer clinical trials.

The log-rank test became the standard method for comparing survival curves, particularly in randomized controlled trials.

Related Calculations

Summary

The log-rank test compares survival distributions between groups by comparing observed to expected events at each time point. It's the standard test for survival curve comparison in clinical trials. Results are interpreted like chi-square tests: p < 0.05 suggests significant difference. Assumes proportional hazards; use weighted versions if early events matter more or curves cross. Always accompany with Kaplan-Meier curves, median survival times, and hazard ratios for complete reporting.