This vignette covers changes between versions 0.2.4 and 0.2.5 for specifiyng weights in the log-rank comparisons done in
ggsurvplot().
As it is stated in the literature, the Log-rank test for comparing survival (estimates of survival curves) in 2 groups (\(A\) and \(B\)) is based on the below statistic
\[LR = \frac{U^2}{V} \sim \chi(1),\]
where \[U = \sum_{i=1}^{T}w_{t_i}(o_{t_i}^A-e_{t_i}^A), \ \ \ \ \ \ \ \ V = Var(U) = \sum_{i=1}^{T}(w_{t_i}^2\frac{n_{t_i}^An_{t_i}^Bo_{t_i}(n_{t_i}-o_{t_i})}{n_{t_i}^2(n_{t_i}-1)})\] and
also remember about few notes
\[e_{t_i}^A = n_{t_i}^A \frac{o_{t_i}}{n_{t_i}}, \ \ \ \ \ \ \ \ \ \ e_{t_i}^B = n_{t_i}^B \frac{o_{t_i}}{n_{t_i}},\] \[e_{t_i}^A + e_{t_i}^B = o_{t_i}^A + o_{t_i}^B\]
that’s why we can substitute group \(A\) with \(B\) in \(U\) and receive same results.
Regular Log-rank comparison uses \(w_{t_i} = 1\) but many modifications to that approach have been proposed. The most popular modifications, called weighted Log-rank tests, are
n Gehan and Breslow proposed to use \(w_{t_i} = n_{t_i}\) (this is also called
generalized Wilcoxon),srqtN Tharone and Ware proposed to use \(w_{t_i} = \sqrt{n_{t_i}}\),S1 Peto-Peto’s modified survival estimate \(w_{t_i} = S1({t_i}) =
\prod_{i=1}^{T}(1-\frac{e_{t_i}}{n_{t_i}+1})\),S2 modified Peto-Peto (by Andersen) \(w_{t_i} = S2({t_i}) =
\frac{S1({t_i})n_{t_i}}{n_{t_i}+1}\),FH Fleming-Harrington \(w_{t_i} = S(t_i)^p(1 - S(t_i))^q\).Note: the Fleming-Harrington weight uses \(S(t^-)\) which is the left-continuous Kaplan-Meier estimate (the value just before time \(t\)).
The regular Log-rank test is sensitive to detect differences in late
survival times, where Gehan-Breslow and Tharone-Ware propositions might
be used if one is interested in early differences in survival times.
Peto-Peto modifications are also useful in early differences and are
more robust (than Tharone-Whare or Gehan-Breslow) for situations where
many observations are censored. The most flexible is Fleming-Harrington
method for weights, where high p indicates detecting early
differences and high q indicates detecting differences in
late survival times. But there is always an issue on how to detect
p and q.
Remember that test selection should be performed at the research design level! Not after looking in the dataset.
After preparing a functionality for this GitHub’s issue Other tests than log-rank for testing survival curves and Log-rank test for trend we are now able to compute p-values for various Log-rank test in survminer package. Let as see below examples on executing all possible tests.
ggsurvplot(fit, data = lung, pval = TRUE, pval.method = TRUE,
log.rank.weights = "n", pval.method.coord = c(5, 0.1),
pval.method.size = 3)ggsurvplot(fit, data = lung, pval = TRUE, pval.method = TRUE,
log.rank.weights = "sqrtN", pval.method.coord = c(3, 0.1),
pval.method.size = 4)ggsurvplot(fit, data = lung, pval = TRUE, pval.method = TRUE,
log.rank.weights = "S1", pval.method.coord = c(5, 0.1),
pval.method.size = 3)weighted_logrank() functionThe examples above annotate a single weighted test on a plot. When
you want the tests themselves – the statistic, its degrees of freedom
and the p-value – as a tidy table, use weighted_logrank().
It takes vectors of rho and gamma, so you can
compute a whole family of Fleming-Harrington G(rho, gamma) tests in one
call. The classic three are FH(0, 0) (the standard log-rank), FH(1, 0)
(early-emphasis, the Peto-Peto / Prentice weighting), and FH(0, 1)
(late-emphasis):
weight rho gamma statistic df p.value
1 FH(0, 0) 0 0 10.326742 1 0.0013111645
2 FH(1, 0) 1 0 12.714151 1 0.0003628989
3 FH(0, 1) 0 1 3.459984 1 0.0628709170
Each row is one test with its weight, rho,
gamma, chi-square statistic, df
and p.value. Here the early-emphasis FH(1, 0) test gives
the smallest p-value and the late-emphasis FH(0, 1) test the largest,
which tells you the two survival curves separate more in early follow-up
than late – the kind of shape a single log-rank p-value hides.
The same arbitrary (rho, gamma) are available inside
ggsurvplot() through log.rank.weights = "FH"
with rho = and gamma =, and
surv_pvalue() now returns the test statistic
and df alongside the p-value:
variable pval method pval.txt statistic df
1 sex 0.0629 Fleming-Harrington (rho=0, gamma=1) p = 0.063 3.459984 1
Gehan A. A Generalized Wilcoxon Test for Comparing Arbitrarily Singly-Censored Samples. Biometrika 1965 Jun. 52(1/2):203-23.
Tarone RE, Ware J 1977 On Distribution-Free Tests for Equality of Survival Distributions. Biometrika;64(1):156-60.
Peto R, Peto J 1972 Asymptotically Efficient Rank Invariant Test Procedures. J Royal Statistical Society 135(2):186-207.
Fleming TR, Harrington DP, O’Sullivan M 1987 Supremum Versions of the Log-Rank and Generalized Wilcoxon Statistics. J American Statistical Association 82(397):312-20.
Billingsly P 1999 Convergence of Probability Measures. New York: John Wiley & Sons.