# Logrank test

The logrank test (sometimes called the Mantel-Haenszel test or the Mantel-Cox test) [1] is a hypothesis test to compare the survival distributions of two samples. It is a nonparametric test and appropriate to use when the data are right censored (technically, the censoring must be non-informative). It is widely used in clinical trials to establish the efficacy of new drugs compared to a control group (often a placebo) when the measurement is the time to event (such as a heart attack).

## Definition

The logrank test statistic compares estimates of the hazard functions of the two groups at each observed event time. It is constructed by computing the observed and expected number of events in one of the groups at each observed event time and then adding these to obtain an overall summary across all time points where there is an event.

Let j = 1, ..., J be the distinct times of observed events in either group. For each time ${\displaystyle j}$, let ${\displaystyle N_{1j}}$ and ${\displaystyle N_{2j}}$ be the number of subjects "at risk" (have not yet had an event or been censored) at the start of period ${\displaystyle j}$ in the groups respectively. Let ${\displaystyle N_{j}=N_{1j}+N_{2j}}$. Let ${\displaystyle O_{1j}}$ and ${\displaystyle O_{2j}}$ be the observed number of events in the groups respectively at time ${\displaystyle j}$, and define ${\displaystyle O_{j}=O_{1j}+O_{2j}}$.

Given that ${\displaystyle O_{j}}$ events happened across both groups at time ${\displaystyle j}$, under the null hypothesis ${\displaystyle O_{1j}}$ has the hypergeometric distribution with parameters ${\displaystyle N_{j}}$, ${\displaystyle N_{1j}}$, and ${\displaystyle O_{j}}$. This distribution has expected value ${\displaystyle E_{j}=O_{j}{\frac {N_{1j}}{N_{j}}}}$ and variance ${\displaystyle V_{j}={\frac {O_{j}(N_{1j}/N_{j})(1-N_{1j}/N_{j})(N_{j}-O_{j})}{N_{j}-1}}}$.

The logrank statistic compares each ${\displaystyle O_{1j}}$ to its expectation ${\displaystyle E_{j}}$ under the null hypothesis and is defined as

${\displaystyle Z={\frac {\sum _{j=1}^{J}(O_{1j}-E_{j})}{\sqrt {\sum _{j=1}^{J}V_{j}}}}.}$

## Asymptotic Distribution

If the two groups have the same survival function, the logrank statistic is approximately standard normal. A one-sided level ${\displaystyle \alpha }$ test will reject the null hypothesis if ${\displaystyle Z>z_{\alpha }}$ where ${\displaystyle z_{\alpha }}$ is the upper ${\displaystyle \alpha }$ quantile of the standard normal distribution. If the hazard ratio is ${\displaystyle \lambda }$, there are ${\displaystyle n}$ total subjects, ${\displaystyle d}$ is the probability a subject in either group will eventually have an event, and the proportion of subjects randomized to each group is 50%, then the logrank statistic is approximately normal with mean ${\displaystyle (\log {\lambda })\,{\sqrt {\frac {n\,d}{4}}}}$ and variance 1.[2] For a one-sided level ${\displaystyle \alpha }$ test with power ${\displaystyle 1-\beta }$, the sample size required is ${\displaystyle n={\frac {4\,(z_{\alpha }+z_{\beta })^{2}}{d\log ^{2}{\lambda }}}}$ where ${\displaystyle z_{\alpha }}$ and ${\displaystyle z_{\beta }}$ are the quantiles of the standard normal distribution.

## Joint Distribution

Suppose ${\displaystyle Z_{1}}$ and ${\displaystyle Z_{2}}$ are the logrank statistics at two different time points in the same study (${\displaystyle Z_{1}}$ earlier). Again, assume the hazard functions in the two groups are proportional with hazard ratio ${\displaystyle \lambda }$ and ${\displaystyle d_{1}}$ and ${\displaystyle d_{2}}$ are the probabilities that a subject will have an event at the two time points. ${\displaystyle Z_{1}}$ and ${\displaystyle Z_{2}}$ are approximately bivariate normal with means ${\displaystyle \log {\lambda }\,{\sqrt {\frac {n\,d_{1}}{4}}}}$ and ${\displaystyle \log {\lambda }\,{\sqrt {\frac {n\,d_{2}}{4}}}}$ and correlation ${\displaystyle {\sqrt {\frac {d_{1}}{d_{2}}}}}$. Calculations involving the joint distribution are needed to correctly maintain the error rate when the data are examined multiple times within a study by a Data Monitoring Committee.

## Relationship to Other Statistics

• The logrank statistic is asymptotically equivalent to the statistic based on the estimate of the hazard ratio from the Cox proportional hazards model.
• The logrank statistic is asymptotically equivalent to the likelihood ratio test statistic for any family of distributions with proportional hazard alternative. For example, if the data from the two samples have exponential distributions.
• If ${\displaystyle Z}$ is the logrank statistic, ${\displaystyle D}$ is the number of events observed, and ${\displaystyle {\hat {\lambda }}}$ is the estimate of the hazard ratio, then ${\displaystyle \log {\hat {\lambda }}\approx Z\,{\sqrt {4/D}}}$. This relationship is useful when two of the quantities are known (e.g. from a published article), but the third one is needed.