Skip to content

FTime to event · Guide test 241

Gehan–Breslow generalized Wilcoxon test

Compares survival curves with weights proportional to the numbers at risk, emphasizing earlier events.

Runs in CodeSplashPython (calls R) example not runR example validated

Do it in CodeSplash

In the app, set it up in Analyze with this method:

Do it in CodeSplash Run this test on your own data, in Python or R.

Bench

Change the design, drag the data, move α. The statistic, its reference distribution and the verdict follow.

Bench · Gehan–Breslow generalized Wilcoxon test

40
40
1.80

Group 1's median event time divided by group 2's; 1 means equal medians.

1.00

Lognormal σ; unequal spreads make the survival curves cross.

1.00
4.0

Censoring times are uniform on (0, follow-up); group 2's median event time is 1.

0.050

Your data

Simulated with known medians and spreads
G14022821G24017840S(t)

Kaplan–Meier curves; ticks mark censored follow-up. Rows under the axis: numbers still at risk. Shaded: the weight each event time gets, w(t) = n(t), the number at risk.

If H₀ were true

χ² = 3.39
  1. The reference: how χ² varies across samples when H₀ is true.
  2. Your statistic, from the data above.
  3. The p-value: the area at least as extreme as yours (p = .065).
  4. The hatched rejection region at α = .050: statistics landing here reject H₀.

The formula

Uw=∑jwj(d1j−Y1jdjYj),Vw=∑jwj2Y1jY2jdj(Yj−dj)Yj2(Yj−1),χ2=Uw2VwU_w=\sum_jw_j\Big(d_{1j}-\frac{Y_{1j}d_j}{Y_j}\Big),\qquad V_w=\sum_jw_j^2\frac{Y_{1j}Y_{2j}d_j(Y_j-d_j)}{Y_j^2(Y_j-1)},\qquad \chi^2=\frac{U_w^2}{V_w}

With your numbers

O1=598, E1=860 (weighted),χ2=3.39,40 eventsO_1 = 598,\ E_1 = 860\ (\text{weighted}),\quad \chi^2 = 3.39,\quad 40\text{ events}
d1j, Y1jd_{1j},\ Y_{1j}
events and numbers at risk in group 1 at event time j
Y1jdj/YjY_{1j}d_j/Y_j
events expected in group 1 if the groups shared one hazard
wjw_j
Y_j, the number at risk: early times count most

The verdict

χ²(1) = 3.39, p = .065

p > α = .050: compatible with H₀

Emphasizes early differences because many people are still at risk; it also depends on the censoring pattern, which can differ between groups.

Statistic
3.392
p-value
0.0655
Gehan–Breslow generalized Wilcoxon test on 40 + 40 subjects with 40 events: χ²(1) = 3.39, p = .065. The p-value is above α = .050, so the data are compatible with H0.

Gehan–Breslow generalized Wilcoxon test on 40 + 40 subjects with 40 events: χ²(1) = 3.39, p = .065. The p-value is above α = .050, so the data are compatible with H₀.

Question and hypotheses

H0: the groups have equal survival/event hazard functions over follow-up.

Assumptions

Independent subjects and independent/noninformative censoring within groups, conditional on the modeled design. Standard weights and variances presume the stated risk-set process. Proportional hazards is a power/interpretation condition for logrank, not necessary for validity under identical survival curves.

Formula

Uw=∑jwj(d1j−Y1jdj/Yj)Vw=∑jwj2Y1jY2jdj(Yj−dj)Yj2(Yj−1)Z=Uw/Vw\begin{gathered}U_w=\sum_jw_j(d_{1j}-Y_{1j}d_j/Y_j)\\[5pt] V_w=\sum_jw_j^2\frac{Y_{1j}Y_{2j}d_j(Y_j-d_j)}{Y_j^2(Y_j-1)}\\[5pt] Z=U_w/\sqrt{V_w}\end{gathered}

Parameters and notation

At event time tj, Ygj is group g at-risk count, dgj its event count; Yj,dj are pooled totals. For more than two groups use a score vector and its covariance, with χ²k−1. wj=Yj, the pooled number at risk.

Structure of the method

At each pooled event time, calculate observed-minus-expected group events and weight that score by the pooled number at risk before summing. The corresponding variance uses squared weights. This is a risk-set-weighted survival comparison and should not be confused with an ordinary rank-sum test that ignores censoring.

Estimated and nuisance parameters

Estimate risk-set/event counts and the chosen variance expression; there is no regression coefficient or hazard ratio inside the weighted score. Weights depend on the pooled observed risk process, so their values change with entry/censoring patterns even though the weighting rule is prespecified.

Settings and design choices

Select the Gehan–Breslow/generalized-Wilcoxon variance convention, stratification, follow-up horizon, and group coding. Larger early risk sets emphasize early differences. The survMisc demonstration computes several methods at once; identify the row with weight n rather than treating the entire printed table as one Gehan result.

Fitting and adaptation

No model fine-tuning applies. Build correct risk sets, use the implementation’s matched covariance, and calibrate under the intended censoring/design assumptions. If comparing multiple weights, report the prespecified primary rule or use an appropriately adjusted joint procedure instead of selecting the most significant row.

Sensitivity and robustness

Inspect differential censoring, event ties, sparse tails, and crossing curves. Some generalized-Wilcoxon formulations have undesirable sensitivity to unequal censoring; naming the variant matters. A weighted rejection is not a simple estimate of an early-treatment hazard ratio, and its emphasis may differ across datasets as risk sets change.

How to use and calibrate

Use asymptotic normal tails for Z, or χ²1 for Z². Report the weight rule, risk-set conventions and censoring assumptions.

Example application

Emphasize earlier survival differences while risk sets are larger.

Interpretation and pitfalls

Watch out

The Gehan–Breslow/generalized Wilcoxon family has variance variants; specify the implementation. Unequal censoring can affect weighting and some variants.

What changed in edition 2

  • New sections: structure of the method, estimated and nuisance parameters, settings and design choices, fitting and adaptation, sensitivity and robustness.

Python and R

Read the n-weighted row (Gehan–Breslow) in the log-rank-type output. The package computes several related weighted tests in one call; identify the named statistic explicitly.

Python · invokes R

Not run — Executed end to end through Rscript · needs Python standard library + Rscript; R packages: survMisc, survival

# Python launcher for the complete R implementation below.
# Requires Rscript on PATH and the listed R packages.
import shutil
import subprocess
rscript = shutil.which("Rscript")
if rscript is None:
    raise RuntimeError("Install R and make Rscript available on PATH.")
r_code = r"""
set.seed(2026)
library(survival)
n<-120;g<-factor(rep(c("A","B"),each=60));event_time<-rexp(n,rate=ifelse(g=="A",.1,.14));censor_time<-rexp(n,.04);d<-data.frame(time=pmin(event_time,censor_time),status=as.integer(event_time<=censor_time),g=g)
s<-survMisc::ten(Surv(time,status)~g,data=d)
survMisc::comp(s,p=1,q=1)
print(attributes(s)[c("lrt","tft","sup")])
"""
# No shell interpolation. A failed R execution raises an error in Python.
result = subprocess.run([rscript, "--vanilla", "-"], input=r_code,
                        text=True, capture_output=True)
print(result.stdout)
if result.stderr:
    print(result.stderr)
result.check_returncode()
R

Validated — Executed successfully in the validation environment · needs survMisc, survival

set.seed(2026)
library(survival)
n<-120;g<-factor(rep(c("A","B"),each=60));event_time<-rexp(n,rate=ifelse(g=="A",.1,.14));censor_time<-rexp(n,.04);d<-data.frame(time=pmin(event_time,censor_time),status=as.integer(event_time<=censor_time),g=g)
s<-survMisc::ten(Surv(time,status)~g,data=d)
survMisc::comp(s,p=1,q=1)
print(attributes(s)[c("lrt","tft","sup")])
Output
                    Q        Var      Z pNorm
1          7.1280e+00 1.9135e+01 1.6295     1
n          3.4900e+02 1.0664e+05 1.0687     6
sqrtN      4.5679e+01 1.2812e+03 1.2761     3
S1         3.5674e+00 8.7171e+00 1.2083     4
S2         3.4811e+00 8.4885e+00 1.1948     5
FH_p=1_q=1 1.1145e+00 6.8455e-01 1.3470     2
              maxAbsZ        Var      Q pSupBr
1          7.2708e+00 1.9135e+01 1.6621      1
n          4.8000e+02 1.0664e+05 1.4699      2
sqrtN      4.6909e+01 1.2812e+03 1.3105      6
S1         4.0187e+00 8.7171e+00 1.3611      5
S2         3.9840e+00 8.4885e+00 1.3674      4
FH_p=1_q=1 1.1806e+00 6.8455e-01 1.4270      3
$lrt
                    Q        Var      Z pNorm
1          7.1280e+00 1.9135e+01 1.6295     1
n          3.4900e+02 1.0664e+05 1.0687     6
sqrtN      4.5679e+01 1.2812e+03 1.2761     3
S1         3.5674e+00 8.7171e+00 1.2083     4
S2         3.4811e+00 8.4885e+00 1.1948     5
FH_p=1_q=1 1.1145e+00 6.8455e-01 1.3470     2

$<NA>
NULL

$sup
              maxAbsZ        Var      Q pSupBr
1          7.2708e+00 1.9135e+01 1.6621      1
n          4.8000e+02 1.0664e+05 1.4699      2
sqrtN      4.6909e+01 1.2812e+03 1.3105      6
S1         4.0187e+00 8.7171e+00 1.3611      5
S2         3.9840e+00 8.4885e+00 1.3674      4
FH_p=1_q=1 1.1806e+00 6.8455e-01 1.4270      3

Sources

Statistics guide v4 (historical):
Python: Executed end to end through Rscript · R: Executed successfully in the validation environment
Reference's record:
Edition 2 review: Python: skip · R: not executed (Rscript unavailable); why not run: Python: Python-to-R bridge; Rscript is unavailable. R code was not executed. Python: Not run in the reference's review: Python-to-R bridge; Rscript is unavailable. R code was not executed. R: Reviewed but not run: R wasn't available to the reference's authors.

From the CodeSplash statistics guide (v4), entry 241, updated from the reference's edition 2 (reviewed 14 November 2026) as STAT241.