Tutorials › Introduction to Statistics › Signed-Rank Calculations With Zeros and Ties

Nonparametric Alternatives · Tutorial 954 of 996

Signed-Rank Calculations With Zeros and Ties

Work through paired-data examples to remove zero differences, assign average ranks to ties, and calculate signed-rank statistics consistently.

Intermediate 9 min read

What You'll Learn

  • Define paired differences consistently and identify which are zero.
  • Apply the usual convention of omitting zero differences before ranking.
  • Assign average ranks to tied absolute differences.
  • Calculate the positive and negative signed-rank sums and the smaller statistic.
  • Check rank totals to detect calculation errors.
  • Recognize why zero-handling conventions must be reported consistently.

Why Zeros and Ties Need Care

The Wilcoxon signed-rank test for paired data uses two pieces of information about each pair: the direction of its difference and the rank of the difference's magnitude. In a clean data set, every difference is nonzero and every absolute difference is distinct. Real data need not be so convenient. A pair may have no change, or several pairs may have the same absolute difference. The calculation remains manageable, but the order of operations matters.

This tutorial focuses on the usual convention for zero differences: omit them, then rank the absolute values of the remaining differences. When absolute differences tie, give each tied observation the average of the ranks they would have occupied. The resulting ranks may be fractional. Keep the direction attached to each observation when adding the positive and negative ranks.

Definition: For paired measurements, define each difference as \(d_i=\text{second measurement}_i-\text{first measurement}_i\). A positive difference indicates an increase from first to second measurement; a negative difference indicates a decrease. Under the usual zero-difference convention, omit every pair with \(d_i=0\). Rank the absolute differences \(|d_i|\) for the remaining pairs from smallest to largest, assigning average ranks to ties. Let \(W_+\) be the sum of ranks for positive differences, \(W_-\) the sum for negative differences, and \(T=\min(W_+,W_-)\) the smaller rank sum.

The original number of pairs is \(n\). After zero differences are omitted, let \(m\) be the number of nonzero differences. It is \(m\), not \(n\), that determines how many ranks are assigned under this convention. The rankings concern the magnitudes \(|d_i|\), not the signed values \(d_i\): a difference of \(-8\) is ranked by magnitude 8.

The Calculation in Order

A reliable calculation has four stages: fix the direction of subtraction, omit zeros, rank the remaining absolute differences, and add the ranks separately by sign. The following process also provides checks against common arithmetic errors.

1
Calculate signed differences.
Use one stated order for every pair, such as second measurement minus first measurement. Record each sign as well as its numerical value.
2
Omit zero differences.
Set aside pairs with no change. Do not assign them ranks under the usual convention. Count the remaining \(m\) differences.
3
Rank absolute differences.
Sort the \(m\) nonzero magnitudes. Assign ranks \(1,\ldots,m\); if values tie, give each tied value the mean of the ranks occupied by the tie.
4
Sum ranks by sign.
Add the ranks attached to positive differences to obtain \(W_+\), and the ranks attached to negative differences to obtain \(W_-\). If requested, report \(T=\min(W_+,W_-)\).

For instance, if three equal absolute differences occupy ranks 4, 5, and 6, each receives the average rank \((4+5+6)/3=5\). The equal observations remain separate observations: each contributes rank 5 to the sum determined by its own sign.

Worked Example: Two Ties and Two Zero Differences

Suppose a hypothetical set of eight paired measurements has differences, calculated as after minus before, of \(+2,-2,0,+5,-8,+5,-1,0\). Find the ranks, \(W_+\), \(W_-\), and \(T\) using the usual zero-difference convention.

First omit the two zero differences, leaving \(m=6\) nonzero differences. Their absolute values are \(2,2,5,8,5,1\). In increasing order, the magnitudes are \(1,2,2,5,5,8\). The two 2s occupy ranks 2 and 3, so each receives \((2+3)/2=2.5\). The two 5s occupy ranks 4 and 5, so each receives \((4+5)/2=4.5\). The 1 receives rank 1, and the 8 receives rank 6.

Difference \(d_i\)Absolute difference \(|d_i|\)RankContribution
+222.5\(W_+\)
-222.5\(W_-\)
0—OmittedNone
+554.5\(W_+\)
-886\(W_-\)
+554.5\(W_+\)
-111\(W_-\)
0—OmittedNone

The positive rank sum is \(W_+=2.5+4.5+4.5=11.5\). The negative rank sum is \(W_-=2.5+6+1=9.5\). Therefore \(T=\min(11.5,9.5)=9.5\). The zero pairs have no contribution because they were omitted before ranking.

Why Average Ranks Preserve the Rank Total

Average ranks are not an arbitrary adjustment. They preserve the total of the ranks that would have been assigned if all observations had distinct magnitudes. This gives a useful arithmetic check even when the individual assigned ranks are fractional.

Justification: Suppose \(k\) observations tie and would occupy consecutive ranks \(r,r+1,\ldots,r+k-1\). Assigning each the average rank gives a combined rank total of \(k\) times that average, which equals the sum of the original rank positions.
$$ k\left(\frac{r+(r+1)+\cdots+(r+k-1)}{k}\right) = r+(r+1)+\cdots+(r+k-1) $$

Consequently, after the usual omission of zeros, the sum of all assigned ranks must be \(1+2+\cdots+m\), whether or not ties occur. The positive and negative sums divide this total:

$$ W_+ + W_- = \frac{m(m+1)}{2} $$

In the first example, \(m=6\), so the rank total is \(6(7)/2=21\). The calculated sums give \(11.5+9.5=21\), as required. This check can identify a missing rank or an incorrectly averaged tie, though it cannot by itself confirm that each sign was recorded correctly.

Worked Example: A Three-Way Tie and a Tie at a Larger Magnitude

In a hypothetical paired-data exercise, seven nonzero differences are \(+3,-3,+3,-6,+9,-6,+12\). An eighth pair has difference zero. Find the signed-rank sums and the smaller statistic.

Omit the zero, leaving \(m=7\). Sort the nonzero absolute differences: \(3,3,3,6,6,9,12\). The three 3s occupy ranks 1, 2, and 3, so each gets average rank \((1+2+3)/3=2\). The two 6s occupy ranks 4 and 5, so each gets average rank \((4+5)/2=4.5\). The 9 receives rank 6, and the 12 receives rank 7.

The three differences with magnitude 3 have signs \(+,-,+\), so their contributions are 2 to \(W_+\), 2 to \(W_-\), and 2 to \(W_+\). The negative difference of \(-6\) contributes 4.5 to \(W_-\); the positive difference of \(+9\) contributes 6 to \(W_+\); the other negative \(-6\) contributes 4.5 to \(W_-\); and \(+12\) contributes 7 to \(W_+\).

Thus \(W_+=2+2+6+7=17\), and \(W_-=2+4.5+4.5=11\). The smaller statistic is \(T=\min(17,11)=11\). As a check, \(m(m+1)/2=7(8)/2=28\), and \(17+11=28\).

A Longer Calculation With Fractional Ranks

Fractional ranks can arise from ties of different sizes, and the ranking step should be completed before either signed sum is calculated. The next example shows how to keep each observation's sign attached while doing that.

Worked Example: Checking Every Rank in a Mixed Data Set

Suppose nine hypothetical paired differences, again defined as after minus before, are \(-0.4,+1.2,+1.2,-2.0,0,+3.1,-3.1,+4.7,-0.8\). Calculate the rank sums and check their total.

There is one zero, so omit it and rank the other \(m=8\) observations. Their sorted absolute differences are \(0.4,0.8,1.2,1.2,2.0,3.1,3.1,4.7\). The two values of 1.2 occupy ranks 3 and 4; each receives \((3+4)/2=3.5\). The two values of 3.1 occupy ranks 6 and 7; each receives \((6+7)/2=6.5\). The remaining ranks are 1 for 0.4, 2 for 0.8, 5 for 2.0, and 8 for 4.7.

DifferenceAbsolute differenceRankSigned rank sum
-0.40.41\(W_-\)
+1.21.23.5\(W_+\)
+1.21.23.5\(W_+\)
-2.02.05\(W_-\)
0—OmittedNone
+3.13.16.5\(W_+\)
-3.13.16.5\(W_-\)
+4.74.78\(W_+\)
-0.80.82\(W_-\)

Adding the positive ranks gives \(W_+=3.5+3.5+6.5+8=21.5\). Adding the negative ranks gives \(W_-=1+5+6.5+2=14.5\). Therefore \(T=14.5\). The rank total is \(8(9)/2=36\), and \(21.5+14.5=36\), confirming the total.

Zero-Difference Conventions and Common Mistakes

The usual convention used throughout these calculations is sometimes called the Wilcox convention: remove zero differences before ranking the absolute differences. This means zeros receive neither a rank nor a contribution to \(W_+\) or \(W_-\). Some software and references offer other zero-handling options. For example, a Pratt convention includes zero magnitudes when determining ranks, then does not add their ranks to either signed sum. Because that changes the ranks assigned to nonzero observations, it can change the resulting statistic. State and follow one convention rather than combining steps from different conventions.

Ties are handled separately from zeros. Under the usual convention, tied nonzero absolute differences share average ranks. Do not break a tie arbitrarily by the order in which observations appear, and do not assign the same integer rank to every tied observation unless that integer is in fact their average rank.

  • Ranking signed values instead of magnitudes. The rank is based on \(|d_i|\). The sign is used afterward to decide which sum receives the rank.
  • Ranking zeros and then deleting them. Under the usual convention, delete zero differences first. Ranking zeros before deletion can shift the other ranks and is a different convention.
  • Giving tied values consecutive full ranks. Replace the occupied rank positions with their average for every observation in the tie.
  • Using the original pair count for the rank total. After omitting zeros, check against \(m(m+1)/2\), where \(m\) is the number of nonzero differences.
  • Reporting only the smaller sum without defining it. Some presentations report \(W_+\), while others use the smaller signed-rank sum \(T\). Give the convention and the underlying sums when clarity matters.
Key takeaway: With the usual zero-difference convention, omit zero pairs first, rank the remaining absolute differences with average ranks for ties, and then sum the ranks according to the original signs. Verify that \(W_+ + W_-=m(m+1)/2\).

These steps establish the signed-rank calculations themselves. Choosing whether the test is appropriate for a particular study and interpreting an inferential result require additional considerations; a rank calculation alone does not answer those questions.

Check Your Understanding

Work through each question using the usual convention of omitting zero differences before ranking.

  1. For differences \(+4,0,-2,+2\), what are the absolute differences to rank, and how many observations are ranked?
  2. If four tied observations occupy ranks 3, 4, 5, and 6, what rank does each receive?
  3. For differences \(+1,-1,+3,-4\), calculate \(W_+\), \(W_-\), and \(T\), showing the tied-rank calculation.
  4. Why must a zero difference be omitted before ranking under the usual convention?
  5. After omitting zeros, a data set has \(m=5\) nonzero differences. What total should all assigned ranks sum to, including when ties occur?