Wilcoxon Signed-Rank Test (Two Dependent Samples)
A nonparametric paired-sample test that uses the signs and ranks of the absolute differences.
It is typically more powerful than the sign test because it uses magnitude information through ranks.
When to use
- You have paired observations (before/after, matched subjects, repeated measures).
- You want to test whether the median of the paired differences is 0 (or equivalently, whether the distribution of differences is centered at 0).
- You do not want to assume normality of the differences (unlike the paired t-test).
This test assumes the distribution of the differences is approximately symmetric about the median.
If symmetry is badly violated, the sign test may be more appropriate.
Setup and hypotheses
Define the paired differences:
\[
d_i = A_i - B_i,\quad i=1,2,\ldots,n_0
\]
Remove or ignore any zero differences (standard approach):
\[
d_i = 0 \ \text{(ties)} \ \Rightarrow \ \text{exclude from ranking}
\]
Let \(n\) be the number of nonzero differences. The hypotheses are:
\[
\begin{aligned}
H_0 &: \operatorname{median}(d)=0 \\
H_1 &: \operatorname{median}(d)\ne 0 \quad \text{(two-sided)} \\
H_1 &: \operatorname{median}(d)>0 \quad \text{(right-tailed)} \\
H_1 &: \operatorname{median}(d)<0 \quad \text{(left-tailed)}
\end{aligned}
\]
Ranking procedure
Compute absolute differences and rank them:
\[
|d_i|,\quad R_i=\operatorname{rank}(|d_i|)
\]
If there are ties among \(|d_i|\), assign midranks (average rank for the tied positions).
Attach the sign to the rank to form a signed rank:
\[
\text{signed rank}_i=\operatorname{sign}(d_i)\,R_i
\]
The calculator shows a table with \(d_i\), \(|d_i|\), ranks, and signed ranks. Zeros can be listed but are not used in the ranked sums.
Test statistics
Define the sum of positive and negative ranks:
\[
\begin{aligned}
W^+ &= \sum_{d_i>0} R_i \\
W^- &= \sum_{d_i<0} R_i
\end{aligned}
\]
The total rank sum is:
\[
W^+ + W^- = \frac{n(n+1)}{2}
\]
Some texts also report:
\[
T=\min(W^+,W^-)
\]
Exact p-value (small samples)
Under \(H_0\), each nonzero difference is equally likely to be positive or negative, so the distribution of \(W^+\)
can be enumerated exactly when ranks are \(1,2,\dots,n\) (i.e., no ties in \(|d_i|\)).
For a two-sided test, a common exact p-value definition is:
\[
p = 2\,\min\{P(W^+\le w^+),\;P(W^+\ge w^+)\}
\]
For one-sided alternatives:
\[
\begin{aligned}
H_1:\operatorname{median}(d)>0 &\Rightarrow p=P(W^+\ge w^+) \\
H_1:\operatorname{median}(d)<0 &\Rightarrow p=P(W^+\le w^+)
\end{aligned}
\]
If \(|d_i|\) ties are present, the exact distribution becomes more complicated; many implementations switch to the normal approximation with tie correction.
Normal approximation (large samples)
For sufficiently large \(n\), \(W^+\) is approximately normal under \(H_0\):
\[
W^+ \approx \mathcal{N}(\mu,\sigma^2)
\]
Mean and variance (with tie correction):
\[
\begin{aligned}
\mu &= \frac{n(n+1)}{4} \\
\sigma^2 &= \frac{n(n+1)(2n+1) - \sum_j (t_j^3-t_j)}{24}
\end{aligned}
\]
where \(t_j\) are the sizes of the tie groups among \(|d_i|\).
With an optional continuity correction, a z-score is:
\[
z \approx \frac{W^+ - \mu \mp 0.5}{\sigma}
\]
(the sign of the \(0.5\) depends on the tail direction).
Then compute p-values using the standard normal CDF \(\Phi(\cdot)\).
Effect size
A simple and popular effect size for the signed-rank test is:
\[
r = \frac{|z|}{\sqrt{n}}
\]
Interpretation is context-dependent, but larger \(r\) indicates stronger evidence of a shift in the paired differences.
Hodges–Lehmann estimator (optional)
A robust point estimate of the typical shift is the Hodges–Lehmann estimator for paired data,
often defined as the median of the Walsh averages:
\[
\hat{\theta}_{HL} = \operatorname{median}\left\{\frac{d_i + d_j}{2}: 1\le i \le j \le n\right\}
\]
A confidence interval can be constructed in several ways; the calculator optionally reports a bootstrap CI
as an accessible, practical option for users.
HL is especially helpful because it provides an interpretable estimate (a typical median shift) rather than only a p-value.
What the visualizations show
- Paired slope graph: lines from \(A_i\) to \(B_i\) with median reference lines to visualize direction and typical change.
- Rank bars: bars for \(R_i\) (rank of \(|d_i|\)), colored by sign to see how the rank mass contributes to \(W^+\) and \(W^-\).
- Signed-rank distribution: exact discrete distribution (when feasible) or a normal curve with shaded tail(s) at the observed statistic.
Reporting (suggested)
If you use the normal approximation, mention tie correction and whether continuity correction was used.