Tutorials › VEE Mathematical Statistics › Exact Two-Sided Signed-Rank Tests

VEE Mathematical Statistics · Sign and Wilcoxon Tests · Tutorial 841 of 880

Exact Two-Sided Signed-Rank Tests

Calculate exact two-sided signed-rank p-values and recognize why different valid conventions can give different answers.

Intermediate 9 min read

What You'll Learn

  • State the assumptions that give the signed-rank statistic its exact null distribution.
  • Construct the conditional distribution of the positive rank sum from sign patterns.
  • Calculate a two-sided p-value by doubling the smaller inclusive tail.
  • Use symmetry to express the two-sided calculation with the smaller of the positive and negative rank sums.
  • Distinguish doubled-tail p-values from probability-ordering p-values.
  • Avoid errors caused by strict tails, omitted outcomes, or doubling without a cap.

Why Two-Sided Signed-Rank Tests Need a Tail Convention

A signed-rank test uses both the signs and the ranks of paired differences. For a two-sided question, evidence against the null can occur in either direction: the positive differences may have unusually large ranks, or the negative differences may. The exact null distribution is discrete, so deciding how to combine the two tails matters. In particular, doubling a tail probability is not the same as reporting one tail, and the result must not exceed 1.

This tutorial treats the exact test when the nonzero absolute differences are distinct. It focuses on the two-sided p-value; the signed ranks themselves and the symmetry assumption underlying the procedure are essential inputs.

Definition: Let \(D_1,\ldots,D_n\) be independent paired differences after subtracting the location specified by the null hypothesis. Assume their distribution is continuous and symmetric about zero. Assume also that none of the observed differences is zero and that their absolute values are distinct. Rank \(|D_i|\) from 1 through \(n\), and let \(W^+\) be the sum of the ranks with positive differences. Let \(W^-\) be the sum of the ranks with negative differences. Then $$ R=W^++W^-=\frac{n(n+1)}{2}. $$ Under the null, conditional on the absolute differences, every assignment of positive and negative signs has probability \(2^{-n}\).

The conditional distribution is therefore obtained by taking all subsets of the ranks \(1,\ldots,n\): each subset represents the ranks assigned positive signs, and its sum is a possible value of \(W^+\). The \(2^n\) sign patterns are equally likely under the null, though several patterns can produce the same rank sum.

The Doubled-Smaller-Tail Convention

A common exact two-sided convention is to find the inclusive lower-tail probability at the observed rank sum, or at its reflection, and double the smaller tail. Since \(W^++W^-=R\), reflecting an observed value \(w\) across the center of the distribution gives \(R-w\). Define \(w_*=\min(w,R-w)\). Then the doubled-smaller-tail p-value is

$$ p_{\mathrm{2tail}}=\min\left\{1,\;2P_0(W^+\leq w_*)\right\}. $$

Here \(P_0\) denotes probability under the null distribution. The inequality is inclusive: outcomes equal to the observed tail value are included. Equivalently, this convention counts rank sums at least as far from the center \(R/2\) as the observed sum. The cap at 1 is necessary because doubling a discrete tail probability can exceed 1.

1
Find the observed positive rank sum.
Add the ranks attached to positive differences to obtain \(W^+_{\mathrm{obs}}\), and calculate \(R=n(n+1)/2\).
2
Choose the lower-side value.
Set \(w_*=\min(W^+_{\mathrm{obs}},R-W^+_{\mathrm{obs}})\). This uses the smaller of the observed positive and negative rank sums.
3
Count the inclusive tail.
From the \(2^n\) equally likely sign patterns, count those with \(W^+\leq w_*\). Divide that count by \(2^n\).
4
Double and cap.
Multiply the tail probability by 2 and take the smaller of that result and 1.

Why Symmetry Justifies the Calculation

Conditional on the absolute differences, each sign pattern is equally likely under the null. Reversing every sign pairs a pattern with its complement: a pattern having positive rank sum \(s\) is paired with one having positive rank sum \(R-s\). Consequently, the null distribution of \(W^+\) is symmetric about \(R/2\).

If the observed sum lies below the center, the lower-tail outcomes \(W^+\leq w_*\) represent one direction of departure, and the reflected upper-tail outcomes \(W^+\geq R-w_*\) represent the other. These tails are disjoint when \(w_*<R/2\), and symmetry gives them equal probability. Their combined probability is therefore twice the lower-tail probability. If the observation is at the center, the distance-based two-sided event includes the whole distribution; the cap in the doubled-tail formula also returns 1.

This reasoning depends on the null sign symmetry. A signed-rank calculation is not justified merely because the data are paired: the distribution of differences must satisfy the symmetry assumption for the signed-rank test. The exact subset-sum distribution stated here also assumes no zero differences and no tied absolute differences. Different handling of zeros or ties changes the ranks and the null distribution.

Worked Example: A Central Rank Sum With Three Pairs

A hypothetical study compares a measurement before and after a procedure for three independent pairs. After subtracting the null difference of zero, the absolute differences are distinct and have ranks 1, 2, and 3. Ranks 1 and 2 are positive; rank 3 is negative. Find the exact doubled-smaller-tail p-value. Assume continuous differences symmetric about zero, no zero differences, and no tied absolute differences. Conditional on these ranks under the null, each of the \(2^3\) sign patterns has probability \(1/8\). No interest-rate or mortality assumption is involved.

Method: enumerate subset sums. The observed positive rank sum and total rank sum are $$ W^+_{\mathrm{obs}}=1+2=3,\qquad R=1+2+3=6. $$ Thus \(w_*=\min(3,6-3)=3\).

The eight equally likely subsets of positive ranks give sums \(0,1,2,3,3,4,5,6\). Equivalently, the counts for sums 0 through 6 are \(1,1,1,2,1,1,1\), totaling 8. Hence $$ P_0(W^+\leq 3)=\frac{1+1+1+2}{8}=\frac{5}{8}=0.6250. $$ The two-sided result is $$ p_{\mathrm{2tail}}=\min\left(1,2\cdot\frac{5}{8}\right)=\min(1,1.25)=1.0000. $$

Check. The observed sum is exactly at the center \(R/2=3\), so every possible rank sum is at least as close to the center as the observation. A two-sided p-value of 1 is consistent with that fact. The common mistake is to report \(0.5000\), perhaps by using only half the sign patterns or by mishandling the inclusive tail. The inclusive tail has probability \(5/8\), and doubling it requires the cap at 1.

Probability Ordering Is a Different Convention

Not every exact two-sided procedure combines tails by doubling. Under a probability-ordering convention, add the null probabilities of all possible values of \(W^+\) whose point probabilities are no greater than the point probability of the observed value:

$$ p_{\mathrm{ord}}= \sum_{\{s:\,P_0(W^+=s)\leq P_0(W^+=W^+_{\mathrm{obs}})\}} P_0(W^+=s). $$

This convention compares the probability of each possible statistic value with the probability of the observed statistic value. It is not the same rule as measuring distance from the center. In a discrete distribution, the two rules can yield different p-values. A reported exact two-sided p-value should therefore be accompanied by its convention when that distinction matters.

Worked Example: A Small Doubled-Tail P-Value

In a hypothetical paired calibration study, four independent devices are measured before and after an adjustment. The four nonzero differences, after subtracting the null difference of zero, are \(-1,+3,-5,-8\) in measurement units. Their absolute values are distinct, with ranks 1, 2, 3, and 4 in that order. Find the exact doubled-smaller-tail p-value. Assume the differences are continuous and symmetric about zero; conditional on the absolute ranks under the null, each sign pattern has probability \(1/16\). No interest-rate or mortality model is involved.

Method: enumerate rank sums. Only rank 2 is positive, so \(W^+_{\mathrm{obs}}=2\). The total is $$ R=\frac{4(5)}{2}=10,\qquad w_*=\min(2,10-2)=2. $$

For ranks 1, 2, 3, and 4, the sixteen sign patterns produce the following counts for \(W^+=0,\ldots,10\):

Rank sum \(s\)012345678910
Number of patterns11122222111

The counts sum to \(16\). The inclusive lower tail through 2 contains \(1+1+1=3\) patterns, so $$ P_0(W^+\leq 2)=\frac{3}{16}=0.1875,\qquad p_{\mathrm{2tail}}=2\left(\frac{3}{16}\right)=\frac{6}{16}=0.3750. $$ The observed rank sum has point probability \(1/16\). The only sums with point probability no greater than \(1/16\) are 0, 1, 2, 8, 9, and 10, whose total probability is \(6/16\). Thus probability ordering also gives \(0.3750\) in this example.

Check. Symmetry gives the same probability for the upper tail \(W^+\geq8\), so the two extreme tails contain \(3+3=6\) patterns. Reporting the one-sided tail \(3/16\) as a two-sided p-value would omit the equally likely departure in the opposite direction.

Worked Example: The Conventions Can Disagree

A hypothetical paired assessment records five independent nonzero differences after subtracting a null difference of zero. The differences have distinct absolute values with ranks 1 through 5; ranks 1 and 4 are positive, and ranks 2, 3, and 5 are negative. Find the doubled-smaller-tail p-value and the probability-ordering p-value. Assume continuous differences symmetric about zero; conditional on the ranks under the null, each of the \(2^5\) sign patterns has probability \(1/32\). No interest-rate or mortality assumption is used.

Doubled-smaller-tail method. The observed positive sum is \(W^+_{\mathrm{obs}}=1+4=5\), and \(R=5(6)/2=15\). Thus \(w_*=\min(5,10)=5\). The subset-sum counts for sums 0 through 15 are $$ 1,1,1,2,2,3,3,3,3,3,3,2,2,1,1,1. $$ They sum to 32. The inclusive lower-tail count through 5 is \(1+1+1+2+2+3=10\), so $$ p_{\mathrm{2tail}}=2\left(\frac{10}{32}\right)=\frac{20}{32}=0.6250. $$

Probability-ordering method. The observed value 5 occurs in three sign patterns, so \(P_0(W^+=5)=3/32\). No possible sum has a point probability greater than \(3/32\): the largest counts in the distribution are 3. Therefore every possible sum satisfies the probability-ordering condition, and $$ p_{\mathrm{ord}}=\frac{32}{32}=1.0000. $$

Check. These different results are not an arithmetic contradiction. The doubled-tail convention measures distance from the center \(15/2\); probability ordering compares point masses. State which convention is being used rather than silently switching between them.

Common Exam Traps

  • Reporting just one tail. A two-sided test includes evidence in either direction. Under the doubled-smaller-tail convention, double the smaller inclusive tail.
  • Using a strict inequality. The observed value belongs in its tail. Use \(W^+\leq w_*\), not \(W^+<w_*\).
  • Doubling without checking the result. If twice the tail exceeds 1, report 1, not a number greater than 1.
  • Assuming all two-sided conventions agree. Probability ordering and doubled tails can differ for a discrete distribution. Name the convention used.
  • Applying the exact subset-sum law when its assumptions fail. Zero differences or tied absolute differences require an explicitly chosen ranking and null-distribution procedure; the distinct-rank calculation above does not cover those cases.
Key takeaway: Under the continuous, symmetric null with distinct nonzero absolute differences, each sign pattern is equally likely. For the doubled-smaller-tail convention, reflect the observed sum using \(R-W^+\), count the inclusive lower tail at \(w_*=\min(W^+,R-W^+)\), double its probability, and cap the result at 1. Probability ordering is a separate convention and can produce a different exact p-value.

Check Your Understanding

Use the stated exact null distribution, and use the doubled-smaller-tail convention unless a question asks for probability ordering. Give probabilities to four decimal places.

  1. With ranks 1, 2, and 3, ranks 1 and 2 are positive and rank 3 is negative. Find \(W^+\), \(R\), and the doubled-smaller-tail p-value. (Answer: \(W^+=3\), \(R=6\), \(p=1.0000\).)
  2. With four distinct ranks, only rank 2 is positive. Find the doubled-smaller-tail p-value. (Answer: \(W^+=2\), \(R=10\), \(p=0.3750\).)
  3. With four distinct ranks, ranks 1 and 3 are positive. Find the doubled-smaller-tail p-value. (Answer: \(W^+=4\), \(R=10\), \(p=0.8750\).)
  4. With five distinct ranks, ranks 1 and 4 are positive. Find the doubled-smaller-tail p-value. (Answer: \(W^+=5\), \(R=15\), \(p=0.6250\).)
  5. For the five-rank result in Question 4, the observed rank sum has point probability \(3/32\), and no rank sum has a larger point probability. Find the probability-ordering p-value, and explain why it need not equal the doubled-tail result. (Answer: \(p_{\mathrm{ord}}=1.0000\); probability ordering compares point probabilities, not distance from the center.)
Clinical Biostats