Log-Rank Test Calculator
Compare survival curves between groups.
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.
Or equivalently:
Where:
- O = observed events
- E = expected events under null hypothesis
- V = variance of O - E
How It Works
At each event time:
- Count who is at risk in each group
- Calculate expected events based on risk proportions
- Sum up (observed - expected) across all event times
- Compare to chi-square distribution with df = groups - 1
Example Calculation
Two groups followed over time:
| Time | At Risk (A) | Events (A) | At Risk (B) | Events (B) |
|---|---|---|---|---|
| 3 | 20 | 1 | 18 | 2 |
| 6 | 18 | 2 | 15 | 1 |
| 9 | 15 | 1 | 13 | 2 |
| 12 | 13 | 2 | 10 | 1 |
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-value | Conclusion |
|---|---|
| p < 0.05 | Survival curves differ significantly |
| p β₯ 0.05 | No significant difference detected |
The test tells you if curves differ, not how they differ. Always inspect Kaplan-Meier curves.
Assumptions
- Independent censoring: Censoring unrelated to survival
- Non-informative censoring: Same across groups
- 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:
| Test | Weights | Emphasizes |
|---|---|---|
| Log-rank (Mantel-Cox) | 1 | All times equally |
| Wilcoxon (Gehan-Breslow) | n at risk | Early 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:
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:
- Perform log-rank within each stratum
- 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):
Tests for linear trend in survival across groups.
Sample Size and Power
Number of events needed:
Where HR is the expected hazard ratio.
| HR | Events needed (80% power, Ξ±=0.05) |
|---|---|
| 0.5 | 52 |
| 0.6 | 96 |
| 0.7 | 186 |
| 0.8 | 422 |
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:
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 Test | Hazard Ratio |
|---|---|
| Hypothesis test | Effect size |
| Overall comparison | Magnitude of difference |
| Nonparametric | From 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
- Kaplan-Meier Calculator β Estimate survival curves
- Hazard Ratio Calculator β Effect size
- Chi-Square Test β Categorical comparison
- Power Calculator β Sample size planning
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.