Wilcoxon Signed-Rank Test Calculator

Hypothesis tests

z-score2.08
Two-sided p-value0.0376
Null mean of W39.0
W-minus (opposite rank sum)12
How this was calculated
  1. Under the null, W has mean 12 x 13 / 4 = 39.0 and standard deviation 12.75.
  2. Continuity correction moves W+ = 66 half a unit toward the mean before standardising.
  3. z = (|66 - 39.0| - 0.5) / 12.75 = 2.08.
  4. Two-sided p-value from the normal approximation: 0.0376; the opposite rank sum W- is 12.

Paired measurements - before and after, left and right, matched twins - call for a paired test, and when the differences cannot be trusted as normal, the signed-rank test is the paired t-test's rank-based understudy. Rank the absolute differences, restore their signs, and sum: if the treatment does nothing, the positive and negative rank sums balance; if it shifts the distribution, one sum swells. This page computes the normal-approximation test from the number of pairs and W+, the sum of the positive ranks.

Enter n (pairs with nonzero difference) and W+. You get the z-score with continuity correction, the two-sided p-value, the null mean of W, and W-, the opposite rank sum. The Mann-Whitney page covers the independent-samples cousin; this one is for pairs.

Worked examples

n 12, W+ 66, z 2.08

(12 · 66)

z-score2.08
Two-sided p-value0.0376
Null mean of W39.0
W-minus (opposite rank sum)12

n 20, W+ 150, z 1.66

(20 · 150)

z-score1.66
Two-sided p-value0.0967
Null mean of W105.0
W-minus (opposite rank sum)60

n 9, W+ 10, z 1.42

(9 · 10)

z-score1.42
Two-sided p-value0.1551
Null mean of W22.5
W-minus (opposite rank sum)35

Ranks with signs

The construction discards zero differences (they carry no directional information), ranks the rest by absolute size, and sums the ranks of the positive differences into W+ and of the negative into W-. The two sums complement each other exactly: W+ + W- = n(n+1)/2, so either determines the other - the calculator prints W- (12 in the first example, where W+ is 66 of a possible 78).

Under the null, W+ has mean n(n+1)/4 and standard deviation sqrt(n(n+1)(2n+1)/24). The normal approximation with a 0.5 continuity correction turns the observed sum into a z: z = (|W+ - mean| - 0.5)/SD. The correction exists because W is a whole number being judged by a smooth curve - it moves 66 to an effective 65.5.

The first example: 12 pairs, W+ 66. Mean 39.0, SD 12.75, z = (66 - 39.0 - 0.5)/12.75 = 2.08, two-sided p = 0.0376. A significant imbalance: the positive differences own the large ranks.

  • W+ + W- = n(n+1)/2, always
  • Null mean n(n+1)/4; SD sqrt(n(n+1)(2n+1)/24)
  • Continuity-corrected normal approximation
  • Primary output: the z-score and its two-sided p-value

Worked examples: three paired studies

The 12-pair study above: z 2.08, p 0.0376, W- only 12 against W+ 66. Significant - the pairing did the work, letting each subject serve as their own control.

Twenty pairs with W+ 150: null mean 105.0, SD 26.79, z = 1.66, p = 0.0967, W- 60. A real imbalance in the ranks that the sample size cannot quite certify at the 5 % line - the classic pilot-study outcome, arguing for more pairs rather than a different test.

Nine pairs with W+ 10: null mean 22.5, SD 8.44, z = 1.42, p = 0.1551, W- 35. Here the small rank sum is the positive one - the imbalance argues the other way, with most rank mass on the negative side. The two-sided p-value is direction-blind by design; the W+/W- split is where the direction lives.

The normal approximation and small n

The exact null distribution of W+ is enumerable - every subset of ranks is equally likely to be the positive set - and for n up to about 15, tables or exact software are the careful route. The normal approximation on this page is the standard large-sample route and behaves well from n of 15-20 upward; the first example at n = 12 sits at its edge, and its p of 0.0376 should be read as 'about 0.04'.

Ties among absolute differences complicate both routes: tied ranks are averaged, and the variance takes a correction the clean formula omits. With a few ties the effect is small; with many, use the corrected variance or an exact permutation.

Zero differences are excluded before ranking and n shrinks accordingly - a design consideration, since a treatment producing many exact zeros spends sample size. Report how many pairs were excluded; 12 analysed pairs out of 20 recruited is a different study from 12 of 12.

Signed-rank versus sign test versus paired t

The sign test uses only the directions, discarding magnitudes: simpler, assumption-light, and noticeably weaker. The signed-rank test's use of rank magnitudes buys most of the t-test's power (asymptotic efficiency about 95 % under normality, better under heavy tails) while keeping the sign test's robustness to outliers - a wild difference becomes merely the top rank.

The paired t-test remains the choice when differences are plausibly normal and the mean difference in original units is the quantity of interest. The signed-rank test's natural estimand is the pseudomedian of the differences (the Hodges-Lehmann estimator), which coincides with the median under symmetric differences.

Symmetry is the signed-rank test's one real assumption: it asks the differences to be symmetrically distributed around their centre. Badly skewed differences argue for the sign test instead - the assumption ladder is explicit, and this page sits on its middle rung.

Reporting paired rank tests

Report W+, W-, n after excluding zeros, the z and p-value with their method (normal approximation here), in the format the examples model: n = 12, W+ 66, W- 12, z 2.08, p 0.0376 is a complete sentence a reader can verify against this page in seconds.

The complement identity is the reader's audit: W+ + W- must equal n(n+1)/2 - 66 + 12 = 78, 150 + 60 = 210, 10 + 35 = 45 in the examples. A reported pair failing this identity is mistyped, full stop.

A median difference (or Hodges-Lehmann estimate) with a confidence interval completes the report by restoring the original units that ranks abstract away. The test says the shift is real; the estimate says how large it is on the scale anyone cares about.

Signed-rank in clinical and lab practice

Before-after studies are the home fixture: pain scores after an intervention, blood pressure after a drug, assay readings after a protocol change - paired, skewed, and often with outliers that would dominate a t-test. The first example's shape (12 pairs, rank sums split 66/12, p 0.0376) is the typical successful pilot in that world.

Laboratory method comparisons use it for the same reason: two instruments measuring the same samples produce paired differences whose distribution is nobody's idea of normal, and the question 'is one systematically higher' is exactly the signed-rank question.

The recurring failure mode in both worlds is analysing the pairs as independent samples with Mann-Whitney instead - discarding the pairing throws away the design's power and can reverse conclusions. If the data arrived in pairs, the analysis must keep them in pairs.

The Hodges-Lehmann companion

A test without an estimate invites the question 'how big is the shift?' and the signed-rank test's matched answer is the Hodges-Lehmann estimator: the median of all pairwise averages of the differences (the Walsh averages). It estimates the pseudomedian shift in original units and comes with a confidence interval from the same rank machinery.

The pairing of test and estimator is the complete report: the p-value from this page (0.0376 in the first example) certifies the shift; the Hodges-Lehmann median states it in the units of the measurement, where clinicians and engineers can judge whether it matters.

Software computes the estimator routinely; the conceptual point for readers of this page is that rank tests are not estimate-free by nature - they simply keep their estimates on the rank side of the family unless asked.

One sentence to carry away

Rank the differences by size, let their signs vote with those ranks, and the imbalance between the two sums - judged against its null mean and spread - is the whole test. When in doubt between the sign test and this one, choose this one unless the differences are badly skewed: the ranks are nearly free power.

Paired data, honestly ranked, will usually tell you more than a larger unpaired sample analysed the wrong way. The pairing is information, and the signed-rank test - W+ 66 against W- 12 in the first example, z 2.08 - is how you spend it.

A note on the direction of a result: the two-sided p-value certifies imbalance, but the clinical meaning lives in which sum is large. W+ of 66 against W- of 12 says the positive differences - improvements, if the differences are coded that way - own the large ranks; W+ of 10 against 35 in the third example says the opposite. Always read the pair of sums beside the p-value; the test's arithmetic is symmetric, but its interpretation never is, and the coding of the differences (after minus before, or the reverse) decides which sum is the good news.

Keep the three examples as a pocket reference: n 12 with W+ 66 is what significance looks like (z 2.08, p 0.0376); n 20 with W+ 150 is what a promising pilot looks like (z 1.66, p 0.0967); n 9 with W+ 10 is what an effect in the unexpected direction looks like before it is believed (z 1.42, p 0.1551).

FAQs

What z do n 12 and W+ 66 give?

2.08, p 0.0376.

What is the null mean of W at n 12?

39.0, with SD 12.75.

What do n 20 and W+ 150 give?

z 1.66, p 0.0967.

And n 9 with W+ 10?

z 1.42, p 0.1551.

What is W- in the first example?

12 - the two rank sums always complement each other.

Why the 0.5 correction?

W is a whole number judged by a smooth curve; it moves 66 to an effective 65.5.

Sources

Related calculators

Mann-Whitney U Test Calculator
Mann-Whitney U test by the normal approximation: z-score with continuity correction, two-tailed p-value and effect size r from the two sample sizes and U.
One-Sample T-Test Calculator
Test a sample mean against a hypothesised population mean: the t statistic, standard error, degrees of freedom, the critical value from the t table, and the verdict at your alpha.
Z-Score Calculator
The z-score of any value in a normal distribution, its percentile, and the share of values above and below it — the standardisation behind test scores and quality control.