| Month | At risk A | At risk B | Deaths | Deaths A (O) | Expected A (E) | V |
|---|---|---|---|---|---|---|
| 2 | 5 | 5 | 1 | 0 | 0.500 | 0.250 |
| 4 | 5 | 4 | 1 | 0 | 0.556 | 0.247 |
| 6 | 5 | 2 | 1 | 1 | 0.714 | 0.204 |
| 8 | 4 | 2 | 1 | 0 | 0.667 | 0.222 |
| 12 | 3 | 1 | 1 | 0 | 0.750 | 0.188 |
| 14 | 3 | 0 | 1 | 1 | 1.000 | 0.000 |
| 30 | 1 | 0 | 1 | 1 | 1.000 | 0.000 |
| Total | 7 | 3 | 5.187 | 1.111 |
Comparing curves: the log-rank test
The question
Two Kaplan-Meier curves differ in a sample. Is the difference larger than chance would produce if the two groups really had the same survival? We cannot compare mean survival times (censoring), and comparing survival at one chosen time wastes most of the data. The log-rank test (Mantel 1966; Peto and Peto 1972) uses the whole curve with a simple idea: at every time a death happens, compare the number of deaths in each group with the number we would expect if the groups did not differ.
Observed and expected deaths
Take one event time \(t_j\). Just before it, \(n_{Aj}\) patients of group A and \(n_{Bj}\) of group B are at risk (\(n_j\) in total), and \(d_j\) of them die. If the groups had the same hazard, each patient at risk would be equally likely to be one of the deaths, so group A would expect a share of the deaths proportional to its share of the risk set:
\[E_{Aj} = d_j \,\frac{n_{Aj}}{n_j}\]
This is a 2×2 table (group × died or not) at each event time. Adding up over all event times gives the observed deaths \(O_A = \sum_j d_{Aj}\) and the expected deaths \(E_A = \sum_j E_{Aj}\). The variance of \(O_A - E_A\) also adds up, with a contribution from each table:
\[V_j = \frac{n_{Aj}\, n_{Bj}\, d_j\,(n_j - d_j)}{n_j^2\,(n_j - 1)}, \qquad \chi^2 = \frac{(O_A - E_A)^2}{\sum_j V_j}\]
Under the null hypothesis of equal survival, \(\chi^2\) follows a chi-square distribution with 1 degree of freedom.
By hand: the ten patients in two groups
Split the ten patients of the Kaplan-Meier page into two groups:
- Group A: 6, 10+, 14, 21+, 30
- Group B: 2, 4, 5+, 8, 12
Group A had \(O_A = 3\) deaths where \(E_A = 5.187\) were expected: fewer deaths than expected, so better survival. The statistic is
\[\chi^2 = \frac{(3 - 5.187)^2}{1.111} = 4.304, \qquad p = 0.038\]
The module gives the same result:
Tests comparing groups
| χ² | df | p | |
|---|---|---|---|
| Log-rank | 4.30 | 1 | .038 |
Two things to notice in Table 1. First, the rows at months 14 and 30 contribute nothing to the variance: only group A is left at risk, so there is nothing to compare. Second, the test is driven by the whole sequence of deaths, not by any single time point.
With \(K\) groups the same observed-minus-expected sums are formed for each group, and the statistic has \(K - 1\) degrees of freedom. A small p-value then says that at least one curve differs from the others, not which one.
Weighted versions
The log-rank test gives every event time the same weight. Its relatives give each 2×2 table a weight \(w_j\) and use \(\sum_j w_j (O_{Aj} - E_{Aj})\) instead. All are valid tests of the same null hypothesis; they differ in which differences they detect best.
| Test | Weight \(w_j\) | Most sensitive to differences … |
|---|---|---|
| Log-rank (Mantel 1966; Peto and Peto 1972) | 1 | spread over the whole follow-up, as under proportional hazards |
| Gehan-Breslow (Gehan 1965) | \(n_j\), the number at risk | early, when many patients are at risk |
| Tarone-Ware (Tarone and Ware 1977) | \(\sqrt{n_j}\) | in between the two |
| Peto-Peto (Peto and Peto 1972) | the pooled survival \(\widehat S(t_j^-)\) | early; less affected than Gehan-Breslow by different censoring in the groups |
On the teaching data, by ECOG group:
Tests comparing groups
| χ² | df | p | |
|---|---|---|---|
| Log-rank | 18.0 | 2 | < .001 |
| Gehan-Breslow | 20.5 | 2 | < .001 |
| Tarone-Ware | 20.4 | 2 | < .001 |
| Peto-Peto | 20.3 | 2 | < .001 |
| Log-rank trend | 16.4 | 1 | < .001 |
| Note. H0: the survival curves are identical. Log-rank weights all event times equally; Gehan-Breslow and Tarone-Ware give more weight to early times, Peto-Peto weights by overall survival. The trend test (1 df) uses the group order as scores. | |||
All the tests agree here. When they disagree, the weights tell you when the curves differ: a Gehan-Breslow test much smaller than the log-rank points to an early difference. Choose the test before looking at the data, usually the log-rank. Trying all of them and reporting the smallest p-value is a form of multiple testing.
The trend test for ordered groups
ECOG 0, 1 and 2 are ordered. The 2-df log-rank test asks whether the three curves differ in any way; the log-rank test for trend gives the groups scores 1, 2, 3 and asks the narrower question, on 1 df, whether survival changes steadily along the order. When the ordering is real, the trend test is more powerful and the conclusion is clearer: “survival worsened with each step of ECOG”. Report it alongside the overall test for ordinal groups (tick Log-rank trend (ordered groups)); it makes no sense for unordered groups such as treatment arms.
What the tests do not tell you
- How large the difference is. The p-value depends on the sample size. For the size of the effect, look at the medians, the survival at fixed times, or a hazard ratio from Cox regression.
- Which groups differ, when there are more than two.
- Whether the difference is due to the grouping variable itself or to something that goes with it (older patients may have a worse ECOG). Adjustment needs a regression model.
Next: Cox regression