Biostatistics Study NotesFrom concepts and derivations to interpretation

CHAPTER 08 · TOPIC 01

Wilcoxon Tests

Distinguish the sign test, rank-sum test for independent groups, and signed-rank test for one-sample or paired data.

On this page
  1. Sign Test: Converting Values to Signs
  2. Sign-Test p Value and Normal Approximation
  3. Rank-Sum Test: Ranking Two Independent Groups Together
  4. Mean, Variance, and Normal Approximation of the Rank Sum
  5. Deriving the Mean and Variance of the Rank Sum
  6. Signed-Rank Test: Using Direction and Ranks of Magnitude
  7. Mean, Variance, and Approximation of the Signed Rank Sum
  8. Choosing among the Three Methods

Wilcoxon rank tests do not assume a normal distribution of raw values, but use signs or ranks to examine differences in location. This page distinguishes between the sign test, the Wilcoxon rank-sum test for two independent groups (Mann–Whitney U), and the Wilcoxon signed-rank test for one sample/paired data.

MethodDesignInformation used
Sign testOne sample or paired dataSigns of the differences only
Rank-sum / Mann–WhitneyTwo independent groupsRanks of all observations
Signed-rankOne sample or paired dataRanks of absolute differences and their signs

Sign Test: Converting Values to Signs#

one sample differenceDi=XiM0D_i=X_i-M_0
paired differenceDi=Xi,afterXi,beforeD_i=X_{i,\mathrm{after}}-X_{i,\mathrm{before}}
signZi={1,Di<00,Di=01,Di>0Z_i=\begin{cases}-1,&D_i<0\\0,&D_i=0\\1,&D_i>0\end{cases}

Let n be the effective sample size after excluding zero differences, and let C be the number of positive differences. Under H₀, positive and negative differences are equally likely, so C follows a binomial distribution.

two-sided hypothesisH0:p=12H1:p12H_0:p=\frac12\qquad H_1:p\ne\frac12
null distributionCH0Binomial(n,12)C\mid H_0\sim\operatorname{Binomial}\left(n,\frac12\right)
mean and varianceE(C)=n2,Var(C)=n4E(C)=\frac n2,\quad\operatorname{Var}(C)=\frac n4

Sign-Test p Value and Normal Approximation#

The exact two-sided p-value sums the binomial probabilities in both tails that are at least as extreme as the observed imbalance. For example, if n=10 and C=8, the following formula is used.

p=2P(C8)=2k=810(10k)(12)10p=2P(C\ge8)=2\sum_{k=8}^{10}\binom{10}{k}\left(\frac12\right)^{10}
large-sample ZZ=Cn/2n/4Z=\frac{C-n/2}{\sqrt{n/4}}
two-sided rejection regionCn2>z1α/2n4\left|C-\frac n2\right|>z_{1-\alpha/2}\sqrt{\frac n4}

Rank-Sum Test: Ranking Two Independent Groups Together#

  1. Pool the N=n+m observations from both groups
  2. Rank them from smallest to largest; assign mean ranks to ties
  3. Sum the ranks in one group to obtain Wₛ
  4. Under permutations of the group labels, calculate the probability of rank sums at least as extreme as the observed value
Ws=igroup 1RiW_s=\sum_{i\in\mathrm{group\ 1}}R_i

Under H₀, the group labels are exchangeable. All C(N,n) assignments of n of the N ranks to the first group are equally likely; counting the assignments that yield rank sum w gives the exact null distribution.

P(Ws=w)=#(w;n,m)(Nn)P(W_s=w)=\frac{\#(w;n,m)}{\binom{N}{n}}

Mean, Variance, and Normal Approximation of the Rank Sum#

null expected valueE(Ws)=12n(N+1)E(W_s)=\frac12n(N+1)
Variance without tiesVar(Ws)=112mn(N+1)\operatorname{Var}(W_s)=\frac1{12}mn(N+1)
Normal approximationZ=WsE(Ws)Var(Ws)Z=\frac{W_s-E(W_s)}{\sqrt{\operatorname{Var}(W_s)}}

Deriving the Mean and Variance of the Rank Sum#

Since each rank is selected C(N−1,n−1) times across all assignments, the expected value can be obtained from the selection ratio n/N and the sum of all ranks N(N+1)/2.

Expected valueE(Ws)=nNi=1Ni=12n(N+1)E(W_s)=\frac nN\sum_{i=1}^{N}i=\frac12n(N+1)
rank sumsi=N(N+1)2,i2=N(N+1)(2N+1)6\sum i=\frac{N(N+1)}2,\quad\sum i^2=\frac{N(N+1)(2N+1)}6
variance resultVar(Ws)=112n(Nn)(N+1)=112nm(N+1)\operatorname{Var}(W_s)=\frac1{12}n(N-n)(N+1)=\frac1{12}nm(N+1)

Signed-Rank Test: Using Direction and Ranks of Magnitude#

  1. Calculate each difference Dᵢ and remove zero differences
  2. Rank |Dᵢ| from smallest to largest; assign mean ranks to ties
  3. Attach each difference’s original sign to its rank
  4. Calculate the positive rank sum T⁺ and negative rank sum T⁻
  5. Obtain the p value from the exact sign distribution or an appropriately corrected normal approximation
Positive rank sumT+=Di>0RiT^+=\sum_{D_i>0}R_i
negative rank sumT=Di<0RiT^-=\sum_{D_i<0}R_i
fixed sumT++T=n(n+1)2T^++T^-=\frac{n(n+1)}2

Under H₀, the distribution of differences is symmetric around zero, and each absolute rank is equally likely to receive a positive or negative sign. The n signs therefore have 2ⁿ equally likely assignments.

Mean, Variance, and Approximation of the Signed Rank Sum#

Expected valueE(T+)=n(n+1)4E(T^+)=\frac{n(n+1)}4
Variance without tiesVar(T+)=n(n+1)(2n+1)24\operatorname{Var}(T^+)=\frac{n(n+1)(2n+1)}{24}
Normal approximationZ=T+n(n+1)/4n(n+1)(2n+1)/24Z=\frac{T^+-n(n+1)/4}{\sqrt{n(n+1)(2n+1)/24}}

Let the indicator Iᵣ equal 1 when rank r receives a positive sign and 0 otherwise. Then T⁺=ΣrIᵣ. Because E(Iᵣ)=1/2 and Var(Iᵣ)=1/4, linearity gives the expressions above.

indicator expressionT+=r=1nrIrT^+=\sum_{r=1}^{n}rI_r
signed rank sumW=T+T,E(W)=0W=T^+-T^-,\quad E(W)=0
variance of WVar(W)=r2=n(n+1)(2n+1)6\operatorname{Var}(W)=\sum r^2=\frac{n(n+1)(2n+1)}6

Choosing among the Three Methods#

MethodSample relationshipPrimary H₀Additional condition
SignOne sample or pairedPositive and negative differences are equally likelyNo symmetry assumption for the differences
Rank-sumTwo independent groupsThe two group distributions are identicalSimilar shapes for a median-shift interpretation
Signed-rankOne sample or pairedThe distribution of differences is centered at zeroSymmetric distribution of differences