Open In App

Log Rank Test

Last Updated : 29 Apr, 2025
Summarize
Comments
Improve
Suggest changes
Share
Like Article
Like
Report

The Log Rank Test is a widely used non-parametric statistical method in survival analysis, Used to compare the survival distributions of two or more groups. It plays an important role in evaluating time-to-event data, making it particularly valuable in clinical trials and healthcare research. Its simplicity and effectiveness make it a cornerstone in analyzing survival data across diverse disciplines.

Mathematical Foundation of the Log Rank Test

The Log Rank Test compares Kaplan-Meier estimator-derived survival curves to see if there are differences among groups. It tests whether the survival functions of the groups are equal or not under the null hypothesis.

Expected Events

For group 𝑖 at time 𝑡𝑗, the expected number of events:

h(t|X) = h_0(t) \cdot e^{\beta X},

where 𝑌𝑗 is the total number of individuals at risk, 𝑌𝑖, 𝑗 is the number at risk in group 𝑖, and 𝑑𝑗 is the total events at 𝑡𝑗.

Log Rank Test Statistic

The test statistic:

Z = \frac{\sum_j (O_{i,j} - E_{i,j})}{\sqrt{\sum_j V_{i,j}}},

where 𝑂𝑖, 𝑗 is the observed events and 𝑉𝑖, 𝑗 is the variance:

V_{i,j} = \frac{Y_{i,j} \cdot (Y_j - Y_{i,j}) \cdot d_j \cdot (Y_j - d_j)}{Y_j^2 \cdot (Y_j - 1)},

Key Features of the Log Rank Test

  1. Non-parametric does not assume a particular distribution for survival times.
  2. Compares survival curves with the Kaplan-Meier estimator.
  3. Tests the null hypothesis that the survival distributions of the groups are the same.

Survival Analysis

Survival analysis examines the time until an event of interest occurs. The event could range from death or relapse in medical studies to failure times in mechanical systems.

Key Concepts

  1. Time-to-Event Data: The primary variable of interest, measured as the time from a defined starting point (e.g., diagnosis) to the occurrence of an event (e.g., death).
  2. Censored Data: When the exact time of the event is unknown for some subjects. For instance, a patient may not experience the event during the study period.
  3. Survival Function (S(t)):

S(t) = P(T > t),

where 𝑇 is the time-to-event variable. 𝑆(𝑡) represents the probability that an individual survives beyond time 𝑡.

Kaplan-Meier Estimates: The Kaplan-Meier (KM) estimator is a non-parametric method used to estimate the survival function 𝑆(𝑡). It accounts for censored data and provides the foundation for the Log Rank Test.

Log-Rank Test for Comparing Survival Distributions in Python

Python
from lifelines.statistics import logrank_test

# Define survival times and event indicators for two groups
g_1 = [5, 6, 7, 8, 10]
g_2 = [4, 6, 8, 9, 12]
e_1 = [1, 1, 1, 1, 1]  # 1 = event occurred, 0 = censored
e_2 = [1, 1, 1, 1, 1]

# Perform the Log-Rank Test
result = logrank_test(g_1, g_2, 
                      e_A= e_1, 
                      e_B= e_2)
print("Test Statistic:", result.test_statistic)
print("P-value:", result.p_value)

Output:

Test Statistic: 0.3276878343596552
P-value: 0.5670237572916402

Alternative Tests for Survival Analysis

While the Log Rank Test is widely used, other tests may be more appropriate in certain cases:

  • Wilcoxon (Breslow) Test: Gives more weight to early events.
  • Tarone-Ware Test: A compromise between the Log Rank and Wilcoxon tests.
  • Cox Regression: Accounts for covariates affecting survival.

Applications of the Log Rank Test

The Log Rank Test is used in:

  • Clinical Trials: Comparing survival times between treatment and control groups.
  • Epidemiology: Studying disease progression and survival rates.
  • Engineering: Analyzing component reliability and failure times.

Advantages

  • Non-parametric: No distributional assumptions.
  • Handles censored data effectively.
  • Widely accepted and easy to compute.

Limitations

  • Assumes proportional hazards.
  • Less sensitive to differences at early or late time points.
  • Does not account for covariates.

Next Article

Similar Reads