Author-reviewedEvidence: highv1.0.1

Wilcoxon Test

The Wilcoxon test in survival analysis, or Gehan-Breslow test, compares survival curves by weighting each event time by the number still at risk.

Status
Published, version 1.0.1
Last reviewed
1 Nov 2026, by Dr Darrin Baines
Report a problem
Tell us if something is wrong or out of date

Concept Architecture

Wilcoxon Test for Comparing Survival Curves

In survival analysis, the Wilcoxon test is the generalised Wilcoxon test of Gehan and Breslow, a rank test of whether trial arms share the same time-to-event experience once censoring is allowed for. It belongs to the weighted log-rank family, and its weight is the number of patients still under observation, so early deaths or progressions count for much more than later ones. Outside survival analysis the name usually means the rank-sum or signed-rank test, which appear here as the origin of the survival version and for their use with trial costs. Health economists meet the survival form when curves separate early and then converge. Its output is a chi-square statistic and a p-value, never a survival gain, so a cost-effectiveness model still needs estimated and extrapolated curves.

Rank tests before and after censoring

Mann and Whitney, in 1947, proposed a statistic UU based on the relative ranks of two samples for testing equality of their distributions, noting that Wilcoxon had proposed an equivalent test in 1945. The R documentation for wilcox.test records that definitions vary, since the rank sum can be reported with or without its minimum value subtracted, and that the adjusted form equals the number of pairs in which an observation from one sample is not greater than one from the other.

A censored survival time is only known to exceed the censoring time, so ordinary ranks fail. Gehan, in 1965, proposed a distribution-free two-sample test extending the Wilcoxon test to samples with arbitrary censoring on the right. Breslow, in 1970, extended this to KK samples and allowed the censoring distributions to differ between populations. The Stata manual describes sts test, wilcoxon as the generalised Wilcoxon test of Breslow (1970) and Gehan (1965).

The statistic as weighted observed minus expected deaths

At each distinct event time the test compares deaths observed in one arm with the number expected if both arms had the same hazard, given who is at risk. Tarone and Ware showed in 1977 that the log-rank and modified Wilcoxon statistics differ only in their weights, which are functions of the number at risk at each death. From the general form in the Stata manual, the two-arm Wilcoxon statistic is as follows.

UG=∑j=1knj(d1j−e1j),e1j=n1j djnjU_{G} = \sum_{j=1}^{k} n_j \left( d_{1j} - e_{1j} \right), \qquad e_{1j} = \frac{n_{1j}\, d_j}{n_j}

where kk is the number of distinct event times, njn_j is the number at risk in both arms just before time tjt_j, n1jn_{1j} is the number at risk in arm 1, djd_j is the number of events at tjt_j, d1jd_{1j} is the number of those in arm 1, and e1je_{1j} is the number expected in arm 1 under the null hypothesis of equal hazards.

VG=∑j=1kn1j n0j dj(nj−dj)nj−1,χG2=UG2VGV_{G} = \sum_{j=1}^{k} \frac{n_{1j}\, n_{0j}\, d_j \left( n_j - d_j \right)}{n_j - 1}, \qquad \chi^2_{G} = \frac{U_{G}^{2}}{V_{G}}

where n0jn_{0j} is the number at risk in arm 0, VGV_{G} is the null variance of UGU_{G} once the squared weight cancels the nj2n_j^2 of the usual variance term, and χG2\chi^2_{G} is compared with a chi-square distribution with one degree of freedom (the Stata manual gives r−1r - 1 for rr groups).

Each weighted term has a reading that links the test back to ranks.

nj(d1j−e1j)=n0j d1j−n1j d0jn_j \left( d_{1j} - e_{1j} \right) = n_{0j}\, d_{1j} - n_{1j}\, d_{0j}

where d0jd_{0j} is the number of events in arm 0 at tjt_j. Each arm 1 death adds the number of arm 0 patients who outlived it and each arm 0 death subtracts the number of arm 1 patients who outlived it, so UGU_{G} is the number of orderable pairs in which the arm 1 patient died first minus the number in which the arm 0 patient died first. Without censoring every pair is ordered, as in Mann and Whitney's UU.

Early weight, censoring and the Peto alternative

The weight falls with every death and with every patient censored or lost. The Stata manual says the test suits hazards thought to vary other than proportionally when censoring patterns are similar across groups, and that its weighting makes it susceptible to differences in censoring between groups. The R survival documentation notes that Peto and Peto showed the Gehan-Wilcoxon test can be badly biased under different censoring patterns. Prentice and Marek, comparing cancer incidence in dogs given bone marrow transplants with controls, found a log-rank significance level of 0.01 against 0.76 for Gehan's test.

The Peto test weights by an estimate of pooled survival instead, and the Stata manual states that it is not affected by differences in censoring patterns, while the R documentation adds that for most data sets the two hardly differ. The Tarone-Ware test uses the square root of the number at risk and sits between the log-rank and Wilcoxon tests, and the Fleming-Harrington test can be tuned towards early or late differences.

Choosing the test before the curves are seen

The log-rank test weights every event equally and, in the Stata manual's words, is most appropriate when hazards are thought to be proportional. The Wilcoxon test gains statistical power over it when the difference lies early, where risk sets are largest, and loses power when curves separate late. Royston and Parmar, simulating nine tests in randomised trials (the Gehan-Wilcoxon test was not among them), found that tests aimed at a particular pattern performed well when the correct type of effect had been assumed, and that a low control-arm event rate reduced the power of weighted log-rank tests aimed at early effects.

A trial expecting early separation, for example from high perioperative mortality in one arm, can prespecify the Wilcoxon test as primary or as a sensitivity analysis. Picking the weighted test with the smallest p-value after seeing the curves inflates the false-positive rate unless multiplicity is controlled, for example by hierarchical testing.

Worked example with curves that meet at 12 months

All numbers in this example are illustrative. A trial randomises 10 patients to a new treatment (arm 1) and 10 to standard care (arm 0) for 12 months. Arm 0 deaths occur at months 1, 2, 3 and 4 and arm 1 deaths at months 6, 8, 9 and 10. The other six in each arm are censored alive at 12 months, so the Kaplan-Meier estimator gives 12-month survival of 0.60 in both arms.

1. Build the risk sets. Each time has a single death, so each variance term is n1jn0jn_{1j} n_{0j}.

Monthn1jn_{1j}n0jn_{0j}d1jd_{1j}e1je_{1j}nj(d1j−e1j)n_j(d_{1j}-e_{1j})n1jn0jn_{1j} n_{0j}
1101000.5000-10100
210900.5263-1090
310800.5556-1080
410700.5882-1070
610610.6250660
89610.6000654
98610.5714648
107610.5385642

2. Sum the score. Arm 1 had 4 deaths against 4.5050 expected, and the weighted score is UG=4×(−10)+4×6=−16U_{G} = 4 \times (-10) + 4 \times 6 = -16.

3. Check it as pairs. Each arm 0 death was outlived by all 10 arm 1 patients (40 pairs favouring arm 1), and each arm 1 death came while six arm 0 patients were alive (24 pairs favouring arm 0). The other 36 pairs are both censored and cannot be ordered, and 40 minus 24 gives 16.

4. Form the statistic. The variance is the sum of the last column, VG=544V_{G} = 544, so χG2=(−16)2/544=0.4706\chi^2_{G} = (-16)^2 / 544 = 0.4706, with a p-value of 0.49.

5. Compare the neighbours. The log-rank test gives U=−0.5050U = -0.5050, V=1.9562V = 1.9562 and χ2=0.1304\chi^2 = 0.1304 (p = 0.72), and the Tarone-Ware test χ2=0.2778\chi^2 = 0.2778 (p = 0.60). The Wilcoxon statistic is over three times the log-rank one because all arm 0 deaths fall where its weights peak. The Peto-Peto-Prentice test also gives 0.4706, since with no censoring before the last death its weight is nj/21n_j / 21, a constant multiple of the Wilcoxon weight.

6. Change the censoring. If three arm 1 patients are instead lost at month 5, the score stays at minus 16, but the later weights shrink and the variance falls to 472, giving χG2=0.5424\chi^2_{G} = 0.5424 (p = 0.46). The Peto-Peto-Prentice statistic drops to 0.2205 and the log-rank statistic to 0.0020, so dropout alone has moved the tests apart.

7. Interpret. No test shows a difference with 20 patients, and none measures benefit. The model quantity is the restricted mean survival time to 12 months, RMST1=6+2(0.9)+0.8+0.7+2(0.6)=10.5\text{RMST}_1 = 6 + 2(0.9) + 0.8 + 0.7 + 2(0.6) = 10.5 months against RMST0=1+0.9+0.8+0.7+8(0.6)=8.2\text{RMST}_0 = 1 + 0.9 + 0.8 + 0.7 + 8(0.6) = 8.2 months, a gain of 2.3 months although 12-month survival is identical.

What a cost-effectiveness model still needs

NICE Decision Support Unit Technical Support Document 14, on survival analysis for economic evaluation, explains that without extrapolation the survival benefit is restricted to the trial period, which is likely to underestimate the survival gain and the QALYs gained. It notes that mean survival equals the area under the survival curve, that parametric models are likely to be the preferred approach in most cases, and that standard survival methods suit only uninformative censoring.

A Wilcoxon p-value neither chooses a distribution nor supplies the curves a partitioned survival model needs. A significant Wilcoxon result beside a non-significant log-rank result is a signal to examine the proportional hazards assumption and how the extrapolation treats the period after early separation.

The rank-sum and signed-rank tests with costs

The R documentation describes the classic pair. The signed-rank test examines whether paired differences, such as utility before and after treatment, are symmetric about a stated value, and the rank-sum test is equivalent to the Mann-Whitney test. It warns that the two-sample location estimate is the median of the differences between an observation from each sample, not the difference in medians.

For costs these tests answer the wrong question. Mihaylova and colleagues note that costs are often positively skewed with heavy tails, that medical statistics has traditionally used rank methods for them, and that it is widely accepted in health economics that the population mean cost is the statistic of interest to policy makers. Thompson and Barber add that the Mann-Whitney U test is an overall comparison of distributions in shape and location, and cite a review of 45 trials published in 1995 in which only half the papers comparing costs used methods addressing arithmetic means. A permutation test or bootstrapping on the mean difference keeps the target the budget decision needs.

Software names and common misreadings

Stata runs the survival test with sts test, wilcoxon (stratified with strata()), and in its heart transplant example the Wilcoxon chi-square is 0.14 (p = 0.71) against 0.13 for the log-rank test. The statsmodels survdiff function takes weight_type="gb", documented as Gehan-Breslow weighting by the number at risk. R survdiff has no number-at-risk weight, and its rho = 1 option is documented as equivalent to the Peto and Peto modification of the Gehan-Wilcoxon test, so an R result labelled Wilcoxon may use the Peto weight.

  1. Mixing up the tests that share the name. A rank-sum test on costs and a survival Wilcoxon test answer different questions, and a report should name the version.
  2. Reading significance as a treatment effect. The test checks equality of survival distributions, and the size of any gain must come from survival estimates, a hazard ratio model or a decision model.
  3. Ignoring the censoring pattern. Unequal dropout or accrual changes the weights, and the Peto-Peto-Prentice test is a check.
  4. Choosing the weight after seeing the curves. Selecting the most favourable weighted test invalidates the nominal significance level.

Sources

Library

Publications

1
  • Guidance

    NICE DSU Technical Support Document 15: Cost-effectiveness modelling using patient-level simulation — Davis, Stevenson, Tappenden & Wailoo, TSD 15 ed., 2014 (NICE Decision Support Unit (University of Sheffield))

    Guidance on individual patient-level (microsimulation) cost-effectiveness modelling — when to use it in preference to cohort models, how to structure it, and how to handle the associated computational and uncertainty challenges.

Frequently Asked Questions (6)

  • What is the Wilcoxon test in survival analysis?

    The Wilcoxon test in survival analysis, or Gehan-Breslow test, compares survival curves by weighting each event time by the number still at risk.

    Source: StataCorp 2025

  • When is the survival Wilcoxon test preferred to the log-rank test?

    The Stata manual describes the log-rank test as most appropriate when hazards are thought to be proportional, and the Wilcoxon (Breslow-Gehan) test as appropriate when hazards vary in other ways and censoring patterns are similar across groups. Because each event time is weighted by the number of patients still at risk, early deaths or progressions count for more than later ones. The Wilcoxon test therefore suits a trial in which the survival curves are expected to separate early and then converge, and it loses power when they separate late. The choice should be prespecified, since picking whichever test gives the smaller p-value after seeing the curves inflates the false-positive rate.

    Source: StataCorp 2025

  • How does the Wilcoxon test weight events?

    At each distinct event time the Wilcoxon test takes the difference between the deaths observed and the deaths expected in a group, given who is at risk, and multiplies it by the number of patients still at risk in both groups. That risk set is largest at the start of follow-up and shrinks with every death and every censored patient, so early events receive the heaviest weights. The log-rank test uses a weight of 1 at every event time, and the Tarone-Ware test uses the square root of the number at risk. Because censoring also shrinks the weights, the Stata manual notes that the Wilcoxon test is susceptible to differences in censoring patterns between groups.

    Source: StataCorp 2025

  • When is the Wilcoxon test used?

    Trial analysts run the Wilcoxon test to check whether two or more groups, such as treatment arms, share the same survivor function when some follow-up times are censored. Stata runs it with sts test, wilcoxon, and adding the strata() option gives a stratified version. In the manual's heart transplant example the Wilcoxon chi-square is 0.14 (p = 0.71) against 0.13 for the log-rank test. The result is a chi-square statistic and p-value for equality of survivor functions, so the size of any survival gain has to come from fitted survival curves or a decision model.

    Source: StataCorp 2025

  • How does the Wilcoxon test differ from the log-rank test?

    Both tests compare the deaths observed in each group with the number expected under equal hazards at every event time. Tarone and Ware showed in 1977 that the log-rank and modified Wilcoxon statistics differ only in the weights given to each death, which are functions of the number at risk. The log-rank test weights every event equally, while the Wilcoxon test weights each event by the number still at risk. Early events therefore count for more in the Wilcoxon test, making it more sensitive to an early difference and less sensitive to a late one. Tarone and Ware also proposed a related statistic, now known as the Tarone-Ware test, which sits between the two.

    Source: Tarone & Ware 1977

  • What are the limitations of the Wilcoxon test?

    The Wilcoxon test can reach a very different conclusion from the log-rank test on the same survival data. Prentice and Marek compared cancer incidence in dogs given bone marrow transplants with control dogs and found a log-rank significance level of 0.01 against 0.76 for Gehan's generalised Wilcoxon test. They showed that the Gehan statistic is open to a serious criticism that does not apply to other Wilcoxon generalisations, and they gained further insight from a time-dependent log-rank test and a proportional hazards regression model. Because its weights are the numbers still at risk, unequal dropout between arms can also move the result, and a significant test gives no estimate of the size of any survival gain.

    Source: Prentice & Marek 1979

Trust Record

Verified by Dr Darrin Baines

British health economist

Professional identity: darrinbaines.org

Verification date: 1 Nov 2026

Content version: 1.0.1

Canonical Identity

Term code
HE-EM-SM-093
Wikidata
Q1751970

Stable URI · Machine-readable · Resolvable · CC BY 4.0