---
tag: 1R358D2T7J
kind: definition
name: Log-rank test
msc: [62N03, 62G10, 62P10]
defines: F6CT1YXZ0G
uses: [087P03NEND, MY8ZZP84NP, Y959NKQ3XW, 05AQE0QR0D, 0A9EB0KQBC]
sources:
  - url: https://en.wikipedia.org/wiki/Logrank_test
---

## Definition

Let two groups give right-[[censored|MY8ZZP84NP]] lifetime data.
Let $t_1 < \dots < t_m$ be the distinct event times in the pooled data.
At $t_j$, let $n_j$ be the number at risk and $d_j$ the number of events in the pooled data.
Let $n_{1j}$ and $d_{1j}$ be the same numbers in group 1.
Set
$$E_j = d_j \frac{n_{1j}}{n_j}, \qquad V_j = d_j \frac{n_{1j}}{n_j} \left(1 - \frac{n_{1j}}{n_j}\right) \frac{n_j - d_j}{n_j - 1},$$
with $V_j = 0$ when $n_j = 1$.
The *log-rank statistic* is
$$Z = \frac{\sum_{j=1}^{m} (d_{1j} - E_j)}{\sqrt{\sum_{j=1}^{m} V_j}}.$$
The *log-rank test* of the null hypothesis that the two groups have the same [[hazard function|Y959NKQ3XW]] rejects at level $\alpha$ when $\abs{Z} > z_{1 - \alpha/2}$.
Here $z_{1 - \alpha/2}$ is the $(1 - \alpha/2)$-quantile of the standard [[normal distribution|05AQE0QR0D]].

## Remarks

Under the null hypothesis and non-informative censoring, $Z$ is approximately standard normal for large samples, and $Z^2$ is approximately [[chi-squared|0A9EB0KQBC]] with $1$ degree of freedom.
Given the numbers at risk, $E_j$ and $V_j$ are the mean and variance of $d_{1j}$ under the hypergeometric distribution.

Example: group 1 has events at times $1$ and $3$, group 2 at times $2$ and $4$, with no censoring.
The pairs $(n_j, n_{1j})$ are $(4, 2)$, $(3, 1)$, $(2, 1)$, $(1, 0)$, with $d_j = 1$ each time and $d_{1j} = 1, 0, 1, 0$.
So $\sum (d_{1j} - E_j) = 1/2 - 1/3 + 1/2 + 0 = 2/3$ and $\sum V_j = 1/4 + 2/9 + 1/4 = 13/18$, which gives $Z \approx 0.78$: no evidence of a difference.

Non-example: comparing the two Kaplan–Meier estimates at a single fixed time, say $t = 2$, is a different test.
It ignores the events at all other times, while the log-rank statistic combines them.
