MerQuR+Statistics Glossary

Statistics Glossary → Wilcoxon Signed-Rank

Wilcoxon Signed-Rankanalysis

A test that needs no normality: it checks whether the differences between two measurements on the same people are balanced around zero or shift systematically in one direction, using the ranks of the differences' sizes together with their signs.

Concept

The paired t-test tests the mean of the differences between two measurements on the same people and, in small samples, assumes these differences are normal. When the differences are skewed, contain a few extreme changes or the measure is ordinal, this assumption weakens. The Wilcoxon signed-rank test uses the rank order and direction of the differences instead of the differences themselves, so a single extreme change cannot dominate the result.

A difference is computed for each person (d = measurement 1 − measurement 2). Zero differences are usually handled separately; the remaining differences are ranked by their absolute size, ignoring sign. The ranks of the positive differences are then summed (T+), as are those of the negative differences (T−). If there is really no change, large and small differences appear about equally often in both directions and T+ and T− come out close. If one is clearly larger than the other, the change is systematically in one direction.

The test assumes that the differences are independent and, under the null hypothesis, symmetric around zero. If the differences are symmetric, the result can be read as being about the median difference; if symmetry fails, the test more generally checks for a tendency of the differences to shift in one direction. The size of the change is reported separately from the p value, with the matched-pairs rank-biserial correlation and the Hodges-Lehmann pseudomedian.

When to use it

  • When two measurements on the same people (before-after, two conditions) or matched pairs are compared and the differences are not normal, the sample is small, or the data are ordinal.
  • If the differences are near-normal and the sample large enough, the paired t-test is more powerful; if the two measurements come from different, independent people, use the Mann-Whitney U test.
  • With three or more measurements on the same people, use the Friedman test; if only the direction of change (up/down) is known and not its size, the sign test is appropriate.

An everyday example

A sleep clinic gives 12 insomnia patients a relaxation exercise for four weeks and measures how long they take to fall asleep after going to bed, before and after. For most patients the time shortens by 10-20 minutes, for one it drops from 90 to 15 minutes, and for one it does not change at all. Because that single large drop distorts the distribution of differences, the Wilcoxon test is used: the unchanged patient is set aside, the sizes of the remaining 11 differences are ranked, and the rank sum of the decreases is compared with that of the increases. If the time shortened for 10 of the 11 patients and p = 0.005, the exercise can be said to shorten the time to fall asleep; the result does not rest on that one large drop.

Parameters in MerQur

Confidence Level (%90, %95, %99, Other/custom 80.0-99.9)

Concept: The confidence level sets how 'sure' the intervals for the location estimate of the difference (Hodges-Lehmann) and for the effect size are, and the threshold (α) for significance decisions. It does not change the test statistic or the p value.

Everyday example: With 95% confidence the exercise might be said to shorten the time to fall asleep by typically 'between 8 and 22 minutes'. Asking for 99% confidence widens the interval; with a small sample of 11 patients, if the requested level cannot be reached exactly, the nearest interval is given.

What it does: α = 1 - confidence level; determines the HL CI based on Walsh averages, the paired rank-biserial CI, and the decision. W, p, and Z do not change.

Effect on the result: The HL asymptotic CI is computed by inverting the test (zero differences are dropped, ties and n' are recounted at each shift). When the requested level is unattainable (C* < 1), the outermost Walsh averages and a warning are given.

On the validation data: depression 90% [0.175, 0.726], 95% [0.01, 0.786], 99% [-0.147, 1.022]. pressure 97.5% lower limit -6.

→ Confidence level and confidence interval

Hypothesis direction (Two-sided, Right-tailed, Left-tailed)

Concept: The direction of the hypothesis states whether the question concerns any change or only an increase or only a decrease. The sign of the difference depends on which measurement is subtracted from which, so the direction must be considered together with the order of the measurements.

Everyday example: If the difference is defined as 'after − before', a shorter time to fall asleep means negative differences, and 'does the exercise shorten the time?' is a left-sided test. If the possibility that the exercise lengthens the time is also taken seriously, a two-sided test is chosen.

What it does: H1: the location of d ≠ 0, > 0, or < 0 (d = first measurement - second measurement).

Effect on the result: p and the displayed statistic change: in two-sided W = min(T+, T-), in one-sided W = T+ (the sum of positive ranks).

On the validation data: depression two-sided W = 5, p = 0.039062; right-tailed W = 40, p = 0.019531; left-tailed p = 0.986328.

→ One-sided and two-sided tests (hypothesis direction)

Zero differences (wilcox, pratt, zsplit)

Concept: Pairs whose difference is exactly zero say nothing about the direction of change and affect how the test works. The classical approach (wilcox) drops these pairs; Pratt's method includes them in the ranking but does not add their ranks to the sums; the zsplit method divides the zeros' ranks equally between the two sums. With many zero differences, the methods can give noticeably different results.

Everyday example: If one patient's time to fall asleep did not change at all, the classical method uses 11 patients instead of 12. Had the measurement been rounded to 5-minute steps, giving zero differences for 4-5 patients, this choice would visibly affect the p value.

What it does: Handling of pairs with d = 0. wilcox: dropped (classical Wilcoxon definition). pratt: included in the ranking, their ranks are dropped afterwards (Pratt, 1959). zsplit: the ranks of zeros are split half and half between T+ and T-.

Effect on the result: Z, p, and rank-biserial change; when zsplit is selected, the permutation p is computed like wilcox.

On the validation data: sleep (1 zero) Z: wilcox -2.6679, pratt -2.7575, zsplit -2.7539. hsb2 (15 zeros) two-sided p: wilcox 0.366265, pratt 0.375337, zsplit 0.375423. Pratt is recommended when zeros carry information (Conover, 1973).

→ Ties and zero differences (rank tests)

Continuity correction (default off)

Concept: The rank sum is a discrete statistic; when it is approximated by the continuous normal distribution, a half-unit shift (the continuity correction) can improve the approximation. The correction makes the p value slightly larger, loses its effect as the sample grows, and has no effect when an exact calculation is made.

Everyday example: With 60 patients the normal approximation would be used, and the continuity correction might raise p from, say, 0.031 to 0.033. With 11 patients the exact p is usually computed and this correction is not needed.

What it does: Shifts T+ by 0.5 toward the mean in the normal approximation.

Effect on the result: p does not change in the exact or automatic-exact path.

On the validation data: depression asymptotic p 0.038152 (off) and 0.044011 (on). sleep 0.003906 in both.

→ Continuity correction (Yates)

Descriptives (checkbox)

Concept: Summarises the two measurements and the differences: count, mean, standard deviation, standard error, median, minimum and maximum, skewness and kurtosis. The skewness and extremes of the differences show why a rank-based test was chosen.

Everyday example: The table shows a median difference of −14 minutes and a mean of −20 minutes; the larger mean shows that a single 75-minute drop pulls it down.

What it does: n, mean, SD, SE, median, minimum, maximum, skewness, kurtosis for the first measurement, the second measurement, and the difference.

Effect on the result: Adds only a descriptive table.

On the validation data: In all five datasets skewness and kurtosis are given with the sample-adjusted (G1, G2) definition (sleep difference M = -1.58, SD = 1.2300, skewness -1.746).

p method (Auto, Exact, Asymptotic)

Concept: In small samples, the null distribution of the rank sum can be computed exactly from all possible arrangements of the signs of the differences. As the sample grows, the distribution approaches the normal and p is found by a normal approximation. With ties or zero differences, the exact distribution changes and a conditional exact calculation is needed.

Everyday example: For 11 patients there are 2¹¹ = 2048 possible arrangements of the signs; a computer tries them all and gives the exact p. With 200 patients the normal approximation would be both fast and accurate enough.

What it does: Automatic: exact if n <= 50 and there are no ties or zeros; with ties or zeros, conditional exact at n <= 13, otherwise the normal approximation. Exact: exact without ties and zeros, conditional exact p with them. Asymptotic: the normal approximation.

Effect on the result: p changes.

On the validation data: depression 0.039062 / 0.039062 / 0.038152 in the three methods. sleep automatic 0.003906 (conditional exact p). Asymptotic hsb2 0.366265.

→ Exact test and exact p-value

Permutation p (None, Exact, Monte Carlo)

Concept: The permutation (sign-flipping) p value rests on the idea that under the null hypothesis each difference is equally likely to be positive or negative: the signs are flipped at random and the statistic is recomputed each time. Even with ties and zero differences it gives a p that does not rely on the normal approximation.

Everyday example: If the exercise really has no effect, whether a patient's time shortens or lengthens is as random as a coin toss. Thousands of fake datasets are made by giving each patient's difference a sign by coin toss; the share as extreme as the observed result is p.

What it does: Produces a conditional p robust to ties and zeros from the sign-flip distribution.

Effect on the result: Extra p row only.

On the validation data: Exact: hsb2 0.3672973, sleep 0.00390625, with Pratt hsb2 0.3762964. Monte Carlo (B = 10000, seed 12345): hsb2 0.3698, within 4 MC SD of the exact value.

→ Permutation p-value

Paired rank-biserial and CI (checkbox)

Concept: The matched-pairs rank-biserial correlation is the difference between the rank sums of positive and negative differences divided by the largest possible total; it ranges from −1 to 1. A value of 1 means all differences are positive, −1 that all are negative, and 0 that the two directions are balanced. Its confidence interval shows how precise this effect is.

Everyday example: If 10 of the 11 differences are drops and the single increase is the third-smallest difference, only 3 of the 66 total rank points come from increases, and r = (3 − 63)/66 ≈ −0.91: the time shortened for almost every patient.

What it does: r = (T+ - T-)/(n(n + 1)/2) (Kerby, 2014) and the Fisher z CI.

Effect on the result: Adds an effect size and CI row; with Pratt selected r also stays within the valid range.

On the validation data: depression r = 0.7778, 95% CI [0.2954, 0.9442]. hsb2 (15 zeros) r = 0.0765, CI [-0.0892, 0.2382].

→ Rank-biserial correlation

HL pseudomedian (checkbox)

Concept: The Hodges-Lehmann pseudomedian is the median of all pairwise averages of the differences (the Walsh averages, including each difference averaged with itself). It is a location estimate consistent with the Wilcoxon test: if the differences are symmetric it estimates their median, and it is more resistant to extreme values than the mean.

Everyday example: Eleven differences produce 66 Walsh averages. If their median is −15 minutes, the exercise can be said to shorten the time to fall asleep by typically about 15 minutes; the single 75-minute drop barely affects this value.

What it does: The median of the Walsh averages of the nonzero differences; the location estimate of d.

Effect on the result: Adds a location estimate row.

On the validation data: depression 0.46; sleep -1.4 (computed with zero differences dropped).

→ Hodges-Lehmann estimator (pseudomedian)

Symmetry of differences (checkbox)

Concept: To interpret the Wilcoxon result as being about the median difference, the differences need to be symmetric around their own centre. The skewness of the differences and its ratio to its standard error (z) give a rough guide to how reasonable this assumption is.

Everyday example: If most differences lie between −10 and −20 minutes while one is −75 minutes, the distribution stretches in one direction and the skewness comes out high. The result should then be read as 'the differences lean systematically towards a decrease' rather than 'the median difference is not zero'.

What it does: Gives the skewness (G1), its SE, and z of the differences to check Wilcoxon's symmetry assumption.

Effect on the result: Adds an assumption check row; the test result does not change.

On the validation data: sleep G1 = -1.7455, SE = 0.6870, z = -2.541: the symmetry assumption is doubtful. depression -0.0955 (SE 0.7171).

→ Skewness

Always shown outputs

Concept: The core results are given together on every run: the number and rank sums of positive and negative differences, the test statistic W, the standard normal value Z, the p value, the effect size r = Z/√n and the confidence interval of the median difference. The ranks table shows at a glance in which direction the change goes and how consistent it is.

Everyday example: The ranks table says '10 patients decreased, 1 increased, 1 unchanged' and shows that the rank sum of the decreases is far larger than that of the increases. With W, p and the confidence interval reported together, readers see both the decision and the size of the change.

What it does: The ranks table (negative and positive n, mean rank, sum, ties), W, Z, p, r = Z/√n', and the median difference CI.

Effect on the result: Written in every run regardless of the options.

On the validation data: The hsb2 ranks table: 88 / 90.27 / 7944; 97 / 95.47 / 9261; 15 ties. Signed Z: hsb2 0.9035, depression 2.0732.

Example on real data

Data: UCLA OARC hsb2 (High School and Beyond, n = 200)

Variables: 1st measurement write (writing score), 2nd measurement read (reading score)

  • Question: Do the writing (write) and reading (read) scores of the same students differ? The Wilcoxon signed-rank test, based on the ranks of the differences in paired measurements, is used.
  • Descriptive: Of the 200 pairs, 97 have write > read, 88 have write < read, and 15 have a zero difference; the test uses the 185 nonzero differences. Positive rank sum 9261, negative rank sum 7944.
  • Result: W = 7944, Z = 0.90, p = 0.366 (tie-corrected normal approximation). The null hypothesis cannot be rejected: there is no significant difference between the two scores.
  • Effect size: r = Z/√n' = 0.066; negligible. The 95% CI for the median difference [-0.5, 2.0] includes zero.
  • Limitation: Zero differences are dropped from the test; in large samples the asymptotic p is computed with the normal (z) approximation (hsb2 0.366).
  • APA: W = 7944.00, Z = 0.90, p = .366, r = .07.

Related concepts

Permutation p-valueAsymptotic (normal) approximationRank-biserial correlationHodges-Lehmann estimator (pseudomedian)Ties and zero differences (rank tests)SkewnessExact test and exact p-valueContinuity correction (Yates)

The numbers in the examples are MerQur's output on independent, publicly available validation data; see the MerQur Technical Note for details.