# Logrank test

### From Ganfyd

Statistical test used to compare survival analysis. ^{[1]} It is based on the same assumptions as the Kaplan-Meier estimator plots and are both methods are used together. Not surprisingly they share the same basic assumptions, namely that how an individual subject fairs is not affected by either censoring or time of recruitment. It can accommodate censored data and the statistical comparison is based on the entire survival data, rather than being based at a specific time points. The calculations are based on sequential chi square testing of various time-points, comparing expected values and observed values.

Although the Logrank test does not require that the two curves are of similar shape, where the shape of the curve differ significantly, the Logrank test is less suitable for meaningful comparison. For instance, in a comparison of a surgical treatment versus a medical treatment, immediate peri-operative deaths may be high in the first few weeks, but surgical treatment may prove the better treatment thereafter. The logrank test is not applicable in these situations and the Breslow test (also known as Wilcoxon test) is preferred. However, curves with subtle differences may be hard to spot and so Logrank test maybe unwittingly used.

## Contents |

## How to do it?

### SPSS (Statistical Package for the Social Sciences)

- To compare 2 groups, need a minimum of 3 columns:
**Time**to event, or if event did not occur, the length of follow-up.**Status**, i.e. did the event occur? Can be specified as 1/0, Y/N, etc. Values can be defined in the 'data' mode.**Factor**, i.e. what is different between the two groups, e.g. adjuvant chemotherapy vs no chemotherapy (again indicated by 1/0 or Y/N).

- Select from menu:
`Analysis -> Survival -> Kaplan-Meier`

- Transfer the data columns to the appropriate boxes with the arrows.
- Define the
`Status`

event, e.g. if survival analysis and death=1, then specify '1'. - Select Logrank test as an option.
- Press
`OK`

### R

Use the **survival** library (details in R manual). ^{[2]}^{[3]}. Load data as a data frame with headings **time**, **status** and **x** (where **x** is the differing factor, e.g. chemotherapy vs no chemotherapy).

- Load library. Type:
`library(survival)`

- The
`Surv`

function processes a list of time and status data to produce a sequence of time values. Values which are censored are suffixed with a`+`

. Usage:^{[4]}`Surv(mydata$time,mydata$status)`

- Use
**survdiff**function:`survdiff(Surv(time, status) ~ x, data = mydata)`

In the example below, the data is stored in **aml**, an example data-set which is part of the **survival** library. This compares patients maintained on chemotherapy and those not:

> survdiff(Surv(time, status) ~ x, data = aml) Call: survdiff(formula = Surv(time, status) ~ x, data = aml) N Observed Expected (O-E)^2/E (O-E)^2/V x=Maintained 11 7 10.69 1.27 3.40 x=Nonmaintained 12 11 7.31 1.86 3.40 Chisq= 3.4 on 1 degrees of freedom, p= 0.0653

## References

- ↑ Bland JM, Altman DG. The logrank test. BMJ (Clinical research ed.) 2004;328:1073. (Direct link – subscription may be required.)
- ↑ R manual entry on
**Surv** - ↑ R manual entry on
**survfit** - ↑ R manual entry on
**Surv**