Log-rank test
Intermediate
What you need first. Nothing else on this path comes first. This page is part of Statistical inference.
In survival analysis, the log-rank test is a nonparametric test comparing the survival distributions of two or more groups by contrasting observed and expected events at each event time. The log-rank test, also called the Mantel–Cox test, is a non-parametric test for comparing the survival distributions of two or more groups. It is the standard companion to the Kaplan–Meier curve: where the Kaplan–Meier estimator draws one survival curve per group, the log-rank test asks whether the curves differ by more than chance alone. It compares the groups’ whole survival experience, from the start of follow-up to its end, rather than survival at any single chosen time point.
Let denote a subject’s true event time, for example time to death or relapse, and let be the survival function and the hazard function, the instantaneous event rate among subjects still at risk at time . For two groups, labelled and , the null hypothesis of the log-rank test is
which is equivalent to for all . The test is built by laying a table at every distinct event time and adding the evidence across times, as in the conditional two-group comparison derived by Cox .[1] It makes no assumption about the shape of or : it is valid, in large samples, whatever the underlying survival distribution, provided censoring is non-informative. It is a test of significance only. It estimates no effect size and supplies no confidence interval, so a significant result must be followed by an estimate, usually a hazard ratio from a Cox model, if the size of the difference matters.
Log-rank test
| Fact | Value |
|---|---|
| Topic | Statistical inference |
| Listed on | Statistical inference |
Two glioma survival curves
Bland and Altman illustrate the test with 51 adults with recurrent malignant gliomas, 20 with astrocytoma and 31 with glioblastoma, followed until death or censoring .[2] The two Kaplan–Meier curves differ, but the gap is wider at some times than at others and eventually disappears, so no single time point gives a fair summary of the difference. The log-rank test instead accumulates the comparison over the whole follow-up period. Summing over all event times, the observed numbers of deaths were in the astrocytoma group and in the glioblastoma group, against and expected if there were truly no difference between the groups. For historical context, their published expected-count shortcut is
as reported by Bland and Altman .[2] This shortcut , summed over groups, does not generally have the same chi-squared null reference as the standard log-rank statistic.
For inference here, use the standard risk-set variance derived by Cox [1] and defined in the next section. Recomputing the distinct event-time risk sets from Bland and Altman’s Table 1 gives , an expected count , and a sum of conditional hypergeometric variances . Subjects censored at an event time are included in that risk set but are not counted as events. Thus
The large-sample reference gives an approximate -value of , providing evidence against equal survival in the two groups. The test says nothing about how much better one group fares. For that, Bland and Altman point to the hazard ratio and the Cox model .[2]
One table at every event time
Let each subject contribute an observed time , where is the censoring time, and an indicator with if the event was observed () and if the observation was censored (). Let the distinct event times in the pooled data be . Only event times matter: a time at which nothing happens, or at which someone is merely censored, contributes no table.
At event time , define the risk set as the subjects still under observation just before , that is, those with . A subject censored exactly at is in the risk set at but in no later risk set. Let be the total number at risk at , let and be the numbers at risk in groups and , so that , and let be the total number of events at , of which occur in group and in group . The information at is then the table
| Group 1 | Group 2 | Total | |
|---|---|---|---|
| Events at | |||
| No event at | |||
| At risk at |
Conditional on the row and column totals of this table, and under , the count has a hypergeometric distribution: if the two groups truly share one hazard, then the events at fall into group in proportion to its share of the risk set. Hence the exact conditional mean and variance of under are
The variance formula applies when . If , the group event count is fixed by the margins and its variance is zero; more generally any table with a deterministic group event count contributes no information. The standardized statistic below requires .
The factor is the finite-population correction of the hypergeometric variance; when only one event occurs at , so , it simplifies to .[3] Cox derives these same finite-population quantities from conditional likelihood for tied failures .[1]
Write for the observed events in group at , and add across all event times:
Here is simply the total number of events observed in group , and is the total number expected in group if were true. The log-rank statistic is
Under , and when the number of events is large, is approximately standard normal, , and therefore is approximately chi-squared on degree of freedom, .[3] Three distinctions matter. First, the hypergeometric mean and variance at each single time are exact, given the margins; it is the normal and chi-squared reference distributions that are approximate, and the approximation needs enough events to be trustworthy. Second, risk sets evolve after events and censoring, so the successive tables are not independent fixed experiments. Under independent censoring and the null event-intensity model, the observed-minus-expected increments have conditional mean zero; the summed conditional variances estimate their accumulated variation. This does not make the final statistic exactly normal. Third, the sign of carries the direction: means group had more events than expected under , hence worse survival, while means fewer events than expected. The usual test is two-sided, referring to the standard normal distribution, or equivalently to the distribution.
Properties
Non-parametric and rank-based. The test assumes no parametric form for the survival or hazard functions. In fact it depends only on the ordering of the event and censoring times, not on the numerical gaps between them: any strictly increasing transformation of time leaves the risk sets, event counts and statistic unchanged. Ties must be preserved under the transformation.
Directional, not omnibus. The log-rank test is not equally sensitive to every way two survival curves can differ. It is most powerful when the hazard ratio is approximately constant over time, that is, when for a single constant , the proportional-hazards or Lehmann-type alternative. Peto and Peto showed that for such alternatives the log-rank test has greater local power than any other rank-invariant test procedure .[4] It is therefore the right test when a roughly constant relative benefit or harm is expected, and the wrong emphasis when the difference is concentrated early or late, or when the curves cross. See the section on assumptions and limits below.
The ratio is informative but is not an estimate with a confidence interval. For group , the ratio estimates its relative event rate: means events arrived faster than the common hazard would predict. Peto and Peto note that these ratios are proportional to the relative incidence rates in the groups .[4] But the test itself attaches no standard error or confidence interval to that ratio, and it is not a hazard-ratio estimate in the sense of a Cox model. A -value from the log-rank test and a hazard ratio from a Cox model answer different questions and should not be substituted for one another.
More than two groups. With groups, summing the group event counts minus their conditional expectations gives a vector ; summing the multivariate hypergeometric covariance matrices gives . The components of sum to zero, and , so the full matrix cannot be inverted. The statistic is , where is a generalized inverse on the estimable contrast space. Its asymptotic null degrees of freedom are , under the usual conditions for a multivariate normal approximation. Normally , and one may equivalently use independent components with an invertible covariance submatrix .[4] In degenerate cases, such as a group leaving observation before any informative event comparison, can be smaller. The reference distribution must then use that actual rank; if , there is no informative comparison. For two groups with positive variance this reduces to . The test compares all groups jointly without identifying which pairs differ; ordered groups can instead be assessed with a prespecified trend contrast .[2]
Stratification. If a categorical factor such as sex or study centre is prognostic, the test can be stratified: the contributions and their variances are computed separately within each stratum and then added across strata, so that comparisons are made only between subjects in the same stratum. The resulting comparison permits different baseline hazards across strata while testing a common direction of group difference.
Weighted variants. The ordinary log-rank statistic weights every event time equally, . A weighted log-rank statistic replaces by and by , for weights determined from information available just before each event. Dividing the weighted sum by the square root of its estimated variance gives an approximately standard normal statistic under the same large-sample null conditions. For example, , the total number at risk, gives greater weight to early event times as the risk sets shrink. Peto and Peto derived a censored-data generalisation of Wilcoxon’s test by scoring observations through the pooled experimental survival curve; they distinguished its behaviour under censoring from Gehan’s earlier scoring procedure .[4] Weights must be chosen before seeing the data: trying several weighted tests and reporting the smallest -value inflates the type I error rate.
Relation to the Cox model. For one binary group covariate with no additional adjustment, the exact conditional tied partial likelihood gives the ordinary log-rank score and information at the null, provided the two analyses use the same risk sets and tie conventions .[1] To see this, condition on the events in the risk set at time . At , every subset of failing subjects has equal probability. The number from group is consequently hypergeometric: differentiating the log likelihood gives , and the negative second derivative gives . Adding these contributions over times produces the ordinary log-rank statistic.
This equality is distinct from the result under Breslow’s or Efron’s approximations, which generally differ when events are tied. For subjects at risk in each group and tied events, both in group , the six possible failing pairs contain , , or group- subjects with probabilities , , and . The exact conditional information is therefore the hypergeometric variance , whereas Breslow’s information is . The score is under both exact conditional and Breslow calculations, so their score statistics are and . With no ties, all three likelihood choices agree. Here the likelihood calculation is exact conditionally; the usual chi-squared calibration of the resulting statistic remains an approximation.
Statistical use
When to use it. The log-rank test is the default first test when two or more Kaplan–Meier curves are to be compared and no covariates need adjustment. It is the right choice when a roughly constant hazard ratio is plausible, it is routinely reported alongside the curves themselves, and it agrees with the null score test for one binary group covariate with no additional adjustment when risk sets and tie conventions agree and the exact conditional tied likelihood is used. It is also the natural test in a randomised trial analysed by intention to treat, where the groups are defined by randomisation and no adjustment is required.
Two small groups, month by month
Two groups of five patients each are followed in months. A marks a censored time.
- Group A: (events at ; one censoring at ).
- Group B: (events at ; one censoring at ).
Take group A as the focal group, so counts A’s events. The distinct event times are .
| 1 | 5 | 5 | 10 | 1 | 1 | |||
| 2 | 4 | 5 | 9 | 1 | 1 | |||
| 3 | 3 | 5 | 8 | 1 | 1 | |||
| 5 | 1 | 5 | 6 | 1 | 1 | |||
| 6 | 0 | 5 | 5 | 0 | 1 | |||
| 7 | 0 | 4 | 4 | 0 | 1 | |||
| 8 | 0 | 3 | 3 | 0 | 1 | |||
| 9 | 0 | 2 | 2 | 0 | 1 |
A few rows deserve a comment. At , only one A patient is still at risk: the other three have had events and the fourth was censored at month , so and . From month onwards no A patient remains at risk at all, so and : once a group’s risk set is empty, later event times contribute nothing to the test, however many events occur in the other group. Adding the rows,
so that
and
For a chi-squared distribution on degree of freedom, the two-sided -value is (computed as to four decimal places). At the level, and indeed at the level, we reject the null hypothesis of equal survival: group A has substantially more events, earlier, than the common hazard would predict.
One warning: this is a teaching example with only ten patients and eight events. The normal and chi-squared reference distributions are large-sample approximations, and with so few events the -value of should be read as illustrative rather than exact; an exact calculation would be preferable at this sample size — but a permutation -value is not automatically the answer. Permuting the observed (time, status) pairs between groups is justified only when those pairs are exchangeable under the null, and a null of equal event-time distributions plus independent censoring within each group does not by itself give exchangeability: the censoring distributions must also be the same in both groups (or the permutation must be restricted within strata with a common censoring pattern). Otherwise, prefer an exact conditional (hypergeometric-based) calculation. The arithmetic, not the -value’s third decimal place, is the point of the example. All numbers above were recomputed independently in the accompanying check script.
Your turn — Two new groups
Two new groups of five patients each are followed in months ( marks censoring):
- Group C: .
- Group D: .
Taking group C as the focal group, compute , and from the table at each distinct event time, and hence , and the two-sided -value. Do you reject the null hypothesis of equal survival at the level?
The distinct event times are . The per-time contributions for group C are:
| 2 | 5 | 5 | 1 | |||
| 3 | 4 | 5 | 1 | |||
| 4 | 3 | 5 | 0 | |||
| 5 | 3 | 4 | 1 | |||
| 6 | 2 | 4 | 0 | |||
| 8 | 1 | 3 | 1 | |||
| 9 | 0 | 3 | 0 | |||
| 10 | 0 | 2 | 0 |
Adding the rows, , , , and . Hence , on degree of freedom, and the two-sided -value is . At the level we do not reject the null hypothesis of equal survival: the excess of events in group C over expectation is well within chance variation. Note the contrast with the worked example, where a similar-sized excess was significant because the variance was smaller and the events were concentrated in one group.
Common misconceptions
“A non-significant log-rank test shows the treatments are equally effective.” It does not. It shows only that the data are compatible with equal survival; with few events the test may have little power, and a real difference may be present but undetected. Absence of evidence is not evidence of absence.
“A significant log-rank test shows a large or clinically important difference.” It does not. The test measures only whether a difference is distinguishable from chance. With thousands of patients, a trivial difference can be highly significant; with few patients, a large difference can be non-significant. Size must come from an estimate, such as the hazard ratio, with a confidence interval.
“The -value is the probability that the null hypothesis is true.” It is not. The -value is the probability, computed under the null hypothesis of equal hazards, of a statistic at least as extreme as the one observed. It is a statement about the data under , not about the probability of itself.
“The log-rank test compares median survival times.” It does not. It compares the whole survival experience, event time by event time. Two groups can have identical medians and still differ significantly by the log-rank test, and two groups can have different medians with a non-significant log-rank result, particularly if the curves cross.
“A significant log-rank test means the proportional-hazards assumption holds.” It does not. The test is most powerful under proportional hazards, but it can reject the null for many other patterns of difference, and it can fail to reject when hazards are grossly non-proportional. Checking proportional hazards is a separate task, for example with Schoenfeld residuals from a Cox model.
“Mantel–Cox, Mantel–Haenszel and Cochran–Mantel–Haenszel are three different tests.” They are names for one family of ideas. The log-rank test is also known as the Mantel–Haenszel test or the Cochran–Mantel–Haenszel test, after the stratified table procedure it adapts .[3] “Mantel–Cox” records the same lineage through Mantel and the connection to Cox’s model; “log-rank” is the name Peto and Peto gave it.
Assumptions and limits
Assumptions. The test rests on the same assumptions as the Kaplan–Meier curve: censoring is unrelated to prognosis, the survival probabilities are the same for subjects recruited early and late in the study, and events happened at the times specified .[2] In the language of the construction above, within each group the event time and the censoring time must be independent, so that the risk set at each event time is a representative sample of the survivors. The groups must be independent of one another. Deviations matter most when they differ between the groups, for example if censoring is heavier, or differently related to prognosis, in one group than in the other .[2] The normal and chi-squared approximations additionally require a reasonable number of events; with very few events the -value is approximate. An exact permutation calculation is safer only under an extra condition: permuting the observed (time, status) pairs between groups requires those pairs to be exchangeable under the null, and equal event-time distributions plus independent censoring within each group do not by themselves give exchangeability — the censoring distributions must also be the same in both groups (or permutation must be restricted within strata with a common censoring pattern). When exchangeability is unavailable, a small-sample procedure must justify its own conditioning and censoring assumptions; the hypergeometric calculation at a single event time alone does not supply an exact null distribution for the statistic across the full follow-up.
What it cannot do. The test is purely a test of significance: it cannot provide an estimate of the size of the difference between the groups or a confidence interval .[2] A hazard ratio and its interval come from a model, not from this test. It does not compare survival at a particular time, medians, or mean survival, and it does not adjust for covariates; for adjustment, use a stratified log-rank test or a Cox model. It also has no power to spare against alternatives it is not aimed at.
Crossing curves and non-proportional hazards. The test is most likely to detect a difference when the risk of an event is consistently greater for one group than for the other, and it is unlikely to detect a difference when the survival curves cross, as can happen when comparing a medical with a surgical intervention .[2] When curves cross, the early contributions have one sign and the late contributions the opposite sign, and they cancel in the sum even though the curves differ markedly. The same cancellation weakens the test whenever the hazard ratio changes substantially over follow-up, for instance with a delayed treatment effect. The curves should always be plotted before the test is run :[2] if they cross, or if the proportional-hazards assumption fails, a weighted log-rank test aimed at the part of follow-up where the difference lives, or a different summary such as restricted mean survival time, may be more informative. The choice among these must be made before looking at the data, not by trying each in turn and keeping the smallest -value.
Connections
- Kaplan–Meier estimator: the log-rank test compares the curves this estimator draws. The two share the risk-set construction and the non-informative-censoring assumption: at each event time, the Kaplan–Meier estimator multiplies by using the same and that appear in the log-rank table.
- Cox proportional hazards model: for one binary group covariate with no additional adjustment, the exact conditional Cox score test at the null agrees with ordinary log-rank for the same risk sets and tie conventions; Breslow and Efron need not agree when events are tied .[1] The Cox model adds what the log-rank test lacks: a hazard-ratio estimate with a confidence interval, covariate adjustment, and a formal check of proportional hazards.
- Survival function: the null hypothesis can be stated as for all ; the test compares entire survival functions, not survival at one time.
- Hazard rate: the null hypothesis can equally be stated as for all , and the test is most powerful when the ratio is constant.
- Censoring statistics: censored subjects leave the risk set after their censoring time and contribute no event; the test is valid only under non-informative, independent censoring, the same assumption the Kaplan–Meier estimator requires.
- Chi-squared test of independence: at each event time the log-rank test is a table test, and the combined statistic is a Mantel–Haenszel-style sum over tables; the asymptotic reference distribution is chi-squared with degrees of freedom equal to the covariance rank, normally for groups.
- Wilcoxon rank-sum test: the log-rank test and the Gehan–Wilcoxon and Peto–Peto tests are all weighted log-rank tests, differing only in the weights . The Wilcoxon generalisations weight early event times more heavily and are the better choice when the difference between curves is concentrated early in follow-up.
Check yourself
- In the worked example, the group A patient censored at month is in the risk set at month but not at month . Why is a censored observation counted as at risk at event times up to and including its censoring time, but at no later event time?
The risk set at an event time is the set of subjects still under observation just before . A subject censored at month was under observation until month : had the event occurred at month , it would have been seen, so the subject was genuinely at risk of an observed event up to that point. After month the subject is no longer followed, so nothing is known about whether or when an event occurred, and the subject cannot contribute to the risk set at month or later. The same convention applies to the event times themselves: a subject who has the event at is in the risk set at and leaves it immediately afterwards.
- Suppose the survival curves of two groups cross: group 1 does worse early in follow-up and better late, so that the contributions are mostly positive at early event times and mostly negative at late ones. What happens to the log-rank statistic, and what should be done instead?
The positive early contributions and the negative late contributions cancel when they are added into , so the total can be close to zero and the statistic small even though the curves differ substantially. The test therefore has little power against crossing curves. The curves should be plotted first so the crossing is seen. A weighted log-rank test aimed at the part of follow-up where the difference is expected, chosen before seeing the data, or a summary that does not rely on a single signed sum, such as restricted mean survival time, is more appropriate. A non-significant log-rank result in this setting must not be reported as evidence that the groups have equal survival.
- A log-rank test comparing two groups gives and . Compute and , and the approximate two-sided -value. Is the result significant at the level?
, so on degree of freedom. The two-sided -value is the probability that a standard normal variable has absolute value at least , which is approximately . Equivalently, the upper tail of a distribution above is about . The result is significant at the level, but only just: the -value is barely below , so the evidence is weak and the conclusion is sensitive to small changes in the data.
History
The log-rank test developed from methods for comparing life tables. Cox’s account identifies Mantel’s 1966 test as the two-group procedure recovered by his conditional-likelihood calculation, connecting the earlier table-based comparison to regression .[1]
The name “log-rank” and the test’s optimality theory came from Peto and Peto in 1972. They derived the log-rank scores from a Lehmann family of survival curves, in which one group’s survival function is a power of the other’s, and showed the resulting test to be the locally most powerful rank-invariant test against such alternatives .[4] In the same paper they generalised Wilcoxon’s rank-sum test to censored data and compared the three rank tests’ efficiencies, reporting asymptotic efficiencies in the absence of censoring: for log-rank against Lehmann alternatives and against normal alternatives, compared with for Wilcoxon’s test against normal alternatives .[4] They also compared their censored-data generalisation of Wilcoxon’s test with Gehan’s earlier procedure and explained how the censoring pattern affects Gehan’s scores .[4]
Cox’s 1972 derivation connected the comparison of survival curves to regression: for one binary group covariate with no additional adjustment, the exact conditional partial likelihood yields the ordinary log-rank score and hypergeometric information at the null, including tied events under matching risk-set and tie conventions .[1] Breslow and Efron tie approximations do not generally preserve that equality. Bland and Altman’s 2004 account illustrates the test’s use in clinical survival comparisons and stresses its distinction from estimating the size of a group difference .[2]
See also
Line chart · Apriori algorithm · Asymptotic analysis · Average treatment effect · Base rate · Bayesian inference · Bayesian model · Bayesian probability
References
- ^ a b c d e f g a. (§7, p. 193) b. (§7, p. 193, eqs. (25)–(27)) c. (§§6–7, pp. 192–193) d. (§§6–7, pp. 192–193) e. (§§6–7, pp. 192–193) f. (§7, p. 193) g. (§§6–7, pp. 192–193) Cox, D. R. (1972). Regression Models and Life-Tables. Journal of the Royal Statistical Society Series B: Statistical Methodology, 34(2), 187–202. https://doi.org/10.1111/j.2517-6161.1972.tb00899.x
- ^ a b c d e f g h i j a. (p. 1073) b. (p. 1073) c. (p. 1073) d. (p. 1073) e. (p. 1073) f. (p. 1073) g. (p. 1073) h. (p. 1073) i. (p. 1073) j. (p. 1073) Bland, J. M. & Altman, D. G. (2004). The logrank test. BMJ, 328(7447), 1073. https://doi.org/10.1136/bmj.328.7447.1073
- ^ a b c a. (§11.4, pp. 466–468) b. (§11.4, pp. 466–468) c. (§11.4, pp. 466–468) James, G., Witten, D., Hastie, T. & Tibshirani, R. (2021). An Introduction to Statistical Learning: with Applications in R (2nd ed.). Springer, New York. https://doi.org/10.1007/978-1-0716-1418-1
- ^ a b c d e f g a. (p. 185) b. (§10, pp. 192–193) c. (§9, p. 192) d. (§6, p. 190) e. (§5.1, pp. 189–190) f. (§7, p. 191) g. (§6, p. 190) Peto, R. & Peto, J. (1972). Asymptotically efficient rank invariant test procedures (with discussion). Journal of the Royal Statistical Society, Series A, 135(2), 185–207. https://doi.org/10.2307/2344317
Cite this page
StatWiki (2026). "Log-rank test." StatWiki. Last updated 2 December 2026. https://www.statwiki.io/articles/log-rank-test.html
@misc{statwiki_log_rank_test,
author = {{StatWiki}},
title = {{Log-rank test}},
year = {2026},
url = {https://www.statwiki.io/articles/log-rank-test.html},
urldate = {2026-12-02},
note = {StatWiki, last updated 2 December 2026}
}