Wilcoxon Signed Rank Test: Concept, Assumptions, Solved Example and Demonstration in Agri Analyze

Wilcoxon Signed Rank Test

Summary

The Wilcoxon Signed Rank Test is a non-parametric statistical test used to compare two related (paired) measurements when the differences are not normally distributed. In extension and survey research, it helps a researcher judge whether a training, demonstration or programme has produced a real change, for example in farmers’ knowledge, attitude, adoption score or yield, by comparing the same respondents before and after. Because it works on the ranks of the differences rather than the raw values, it suits small samples, skewed data and measurements where the size of a difference can be meaningfully ranked. (For single Likert items, where differences are coarse and heavily tied, the sign test is the better choice.) This blog gives a simple explanation of the concept, the methodology, a solved example with interpretation, and a demonstration of the test in Agri Analyze.

1. Introduction

The Wilcoxon Signed Rank Test was proposed by Frank Wilcoxon in 1945. It is the non-parametric alternative to the paired t-test. Instead of using the actual size of the differences between paired observations, it ranks the absolute differences and then compares the sum of ranks of positive differences with the sum of ranks of negative differences. If a treatment has no effect, positive and negative changes should be roughly balanced; a large imbalance indicates a real shift.

Many situations in agricultural extension involve paired data: the same farmers are assessed before and after a training programme, the same plots are measured with and without an intervention, or the same respondents rate two practices. The paired t-test assumes that the differences are normally distributed, which is often not true for small samples or for rating scales. The Wilcoxon test relaxes this assumption.

The test helps researchers answer:

  • Did the central value (median) of the paired differences change after the intervention?
  • Is the observed change large enough to be unlikely due to chance?
  • How strong is the effect?

How is it different from the paired t-test?

Paired t-test

  • Uses the mean of the differences.
  • Assumes the differences are approximately normally distributed.
  • Sensitive to outliers.
  • Needs interval or ratio data.

Wilcoxon Signed Rank Test

  • Uses the ranks of the differences (both direction and relative size).
  • Needs only that the differences can be ranked and are roughly symmetric around their center.
  • Robust to outliers and skewness.
  • Suits ordinal data only when the size of the differences is meaningful, for example summed or averaged scale scores. For single Likert items, use the sign test instead.

2. Popular Use Cases for Extension and Survey Research

(a) Agricultural Extension

  • Knowledge scores of farmers before and after training
  • Change in adoption score after a demonstration or field day
  • Impact of an ICT or mobile advisory service on awareness
  • Before and after comparison of income or yield under a project

(b) Survey Research

  • Change in attitude or perception after exposure to a campaign
  • Comparison of two ratings given by the same respondent (for example, satisfaction with two services)
  • Pre and post evaluation of development programmes

(c) Biometrical and Agronomic Studies

  • Paired plot comparison of two varieties or treatments
  • Before and after soil or crop parameter measurements on the same unit

(d) Social Sciences

  • Change in empowerment, confidence or behavioral scores after an intervention.

3. Assumptions of the Test

  • The data are paired, i.e. two measurements on the same subject or matched units.
  • The dependent variable is measured on at least an ordinal scale, and the size of each difference can be meaningfully ranked. Single Likert items give very coarse, heavily tied differences; use the sign test for them. Summed or averaged Likert scale scores are fine.
  • The pairs are independent of each other.
  • The distribution of the differences is approximately symmetric around its center (it need not be normal).

4. Methodology of the Wilcoxon Signed Rank Test

Step 1: Formulate the Hypotheses

  • H0: The median of the paired differences is zero (no change after the intervention).
  • H1: The median of the paired differences is not zero (two-tailed), or is greater or less than zero (one-tailed).

Strictly, H0 is a statement about the median only when the distribution of the differences is symmetric. Otherwise it is a statement about the pseudomedian, which is the Hodges–Lehmann location estimate (the median of all pairwise averages of the differences).

Step 2: Compute the Differences

For each pair, calculate

di=xi,after-xi,before

Discard pairs where di=0 and reduce n accordingly. From here on, n is the number of non-zero differences.

Step 3: Rank the Absolute Differences

Ignore the signs and rank |di| from smallest (rank 1) to largest. If two or more values tie, assign each the average of the ranks they occupy.

Step 4: Attach Signs to the Ranks

Give each rank the sign of its original difference. Then compute

W+=∑di>0​Ri,W-=∑di<0​Ri

where Ri is the rank of |di|. Check:

W++W-=n(n+1)2

Step 5: Test Statistic

W=min(W+,W-)

Note on conventions: textbooks and critical-value tables use W=min(W+,W-), whereas statistical software (R, and Agri Analyze) reports V=W+. Both conventions lead to the same two-sided p-value, because W+ and W- are mirror images around n(n+1)/4.

For small samples (up to about n=25), W is compared with the critical value from the Wilcoxon table, and H0 is rejected if W≤ critical value. For larger samples, a normal approximation is used:

  • Mean: μW=n(n+1)4
  • Variance: σW2=n(n+1)(2n+1)24-∑(t3-t)48, where the second term is the tie correction and t is the number of tied values in each group
  • Z=W-μWσW, or with continuity correction Z=|W-μW|-0.5σW

Step 6: Effect Size

r=|Z|n

Here n is the number of non-zero pairs. Some texts divide by N, where N=2n is the total number of observations, which gives a smaller r; always state which one you used. Following Cohen (1988), r=0.1 is a small, 0.3 a medium and 0.5 or more a large effect.

Step 7: Decision and Interpretation

If W is less than or equal to the critical value (small samples), or the p-value is less than the chosen significance level (usually 0.05), reject H0 and conclude that there is a significant change. Report the direction of change using the median difference (and the Hodges–Lehmann estimate), along with the effect size.

5. Solved Example (Manual Calculation)

In an extension study, the knowledge score of 10 farmers about integrated pest management was recorded before and after a training programme.

FarmerBeforeAfterd=After-Before|d|Rank of |d|Signed Rank
1455813138.5+8.5
25260884+4
3385012126+6
46066662.5+2.5
54847−111−1
65570151510+10
7425513138.5+8.5
8506212126+6
95864662.5+2.5
10405212126+6

5.1 Why the Wilcoxon test for these data?

The ten differences are −1, 6, 6, 8, 12, 12, 12, 13, 13 and 15 (mean 9.6, median 12, SD 4.84). A Shapiro–Wilk test on the differences gives W=0.863, p=0.082, so normality is not rejected. This should not be read as proof of normality: with only 10 pairs the Shapiro–Wilk test has little power, and the differences are visibly left-skewed because one farmer (−1) is discordant. A paired t-test would also reach the same conclusion here (t=6.28, df = 9, p=0.0001). We use the Wilcoxon test because it does not depend on normality and because this small example is a convenient way to show every step by hand. If the differences were clearly normal, the paired t-test would be slightly more powerful. For a dataset where normality is clearly rejected, see the milk-yield example in our Paired t-test [Video: https://www.youtube.com/watch?v=NEAEITu3lkQ&amp;t=102s].

One caution: the test assumes roughly symmetric differences, and these are mildly left-skewed. We return to this when interpreting the Hodges–Lehmann estimate in Section 8.2.

5.2 Hypothesis

  • H0: Training has no effect on knowledge score (median difference =0).
  • H1: Training changes the knowledge score (median difference ≠0).

5.3 Ranking with Ties

Sorted absolute differences: 1, 6, 6, 8, 12, 12, 12, 13, 13, 15.

  • 1 takes rank 1.
  • The two 6s share ranks 2 and 3, so each gets 2.5.
  • 8 takes rank 4.
  • The three 12s share ranks 5, 6 and 7, so each gets 6.
  • The two 13s share ranks 8 and 9, so each gets 8.5.
  • 15 takes rank 10.

5.4 Sum of Signed Ranks

  • W-=1 (only farmer 5 had a decrease)
  • W+=8.5+4+6+2.5+10+8.5+6+2.5+6=54
  • Check: 54+1=55=10×11/2 ✔

Test statistic: W=min(54,1)=1. Statistical software reports V=W+=54.

5.5 Decision Using the Critical-Value Table

Because n=10 is small, the critical-value table is the decision rule. For n=10 and a two-tailed α=0.05, the critical value is 8. Since W=1≤8, H0 is rejected. (The critical value at α=0.01 is 3, so the result is significant at the 1% level as well.)

5.6 Large-Sample Illustration: Normal Approximation and p-value

The normal approximation is not needed for n=10, but it is what statistical software uses when ties are present, so it is shown here to reconcile with the software output.

  • μW=10×11/4=27.5
  • σW2 before tie correction =10×11×21/24=96.25
  • Tie correction =[(23-2)+(33-3)+(23-2)]/48=(6+24+6)/48=0.75
  • σW2=96.25-0.75=95.5, so σW=9.772
  • Without continuity correction: Z=(1-27.5)/9.772=-2.71
  • With continuity correction: Z=(|1-27.5|-0.5)/9.772=26/9.772=2.66, i.e. Z=-2.66

The two-tailed p-value from the normal approximation with tie and continuity corrections is p=0.0078. This is the p-value we report, and it is the one the software gives. (As a cross-check, an exact permutation test that respects the ties gives p=0.0039; the exact value is smaller, so the normal approximation is the more conservative of the two.)

5.7 Effect Size

r=2.66/10=0.84, a large effect by Cohen’s benchmarks. If the total number of observations is used instead (N=20), r=2.66/20=0.59, which is still large.

5.8 Final Result Table

StatisticValue
n (non-zero pairs)10
W+ (reported by software as V)54
W-1
W=min(W+,W-)1
Critical value (n=10, α=0.05, two-tailed)8
Z (tie and continuity corrected)−2.66
p-value (two-tailed, normal approximation with tie and continuity corrections)0.0078
Median of the differences12
Hodges–Lehmann estimate10
Effect size r (n=10)0.84

5.9 Interpretation

  • Decision: Since W=1≤8 (and p=0.0078<0.05), H0 is rejected. There is a statistically significant change in knowledge score after the training.
  • Direction: Nine of the ten farmers improved, and only one showed a small decline of 1 point. The positive ranks (W+=54) dominate the negative ranks (W-=1).
  • Magnitude: The median improvement is 12 points, and the effect size r=0.84 indicates a large effect.
  • Practical meaning: Within this small group, knowledge scores were clearly higher after the training than before.
  • Caution: With only 10 farmers and no comparison group, the result should be confirmed with a larger sample. A significant result shows a change, not necessarily that the training alone caused it, unless the design controls for other factors.

6. How to Report the Result

A Wilcoxon signed rank test showed a significant increase in farmers’ knowledge scores after the training programme (V=54, n=10, Z=-2.66, p=0.008, r=0.84). The median difference was 12 points (Hodges–Lehmann estimate = 10).

7. Steps to Perform the Wilcoxon Signed Rank Test using Agri Analyze

Agri Analyze is a tool that helps researchers perform non-parametric tests online without any software installation

Step 1: Open the tool. Open the Wilcoxon Signed Rank Test page of Agri Analyze: https://www.agrianalyze.com/WilcoxonSignedRankTest. For first-time users, free registration is mandatory.

Step 2: Prepare the CSV file. Create a CSV file with one column for the before (pre) measurement and one column for the after (post) measurement. Each row is one respondent. Sample layout (the data of our solved example):

FarmerKnowledge Score BeforeKnowledge Score After
14558
25260
33850
46066
54847
65570
74255
85062
95864
104052

Step 3: Upload the file and set the options. Upload the CSV file, select the Before and After columns, and set the options: the significance level (α, usually 0.05), the hypothesized median μ (0 for testing paired differences), and the alternative hypothesis (two-sided, greater or less).

Wilcoxon signed-rank test demonstration and results

Step 4: Submit and download the report. Click submit, pay the nominal fee, and download the output report with detailed interpretation. Output report for this example:

Video tutorial: https://www.youtube.com/watch?v=NEAEITu3lkQ&t=102s

Descriptive Statistics of Data

StatisticsKnowledge_Score_BeforeKnowledge_Score_AfterDifference
Mean48.858.49.6
Median49.000059.000012.0000
Variance57.288954.711123.3778
Standard Deviation7.56897.39674.8351
Coefficient of variation15.510112.665650.3652
Inter-quartile range11.510.756.25
Skewness0.0335-0.0369-0.8943
Kurtosis-1.5852-1.4539-0.4046

Box plot

Wilcoxon signed-rank test demonstration and results

Distribution of the differences (solid line = 0, dashed line = median; check for symmetry)

Wilcoxon signed-rank test demonstration and results

Positive vs negative ranks (signed-rank distribution)

Wilcoxon signed-rank test demonstration and results

Additional Plot (non-parametric)

Wilcoxon signed-rank test demonstration and results

Shapiro-Wilk test on the differences (used to justify a non-parametric test)

Null hypothesis (Ho): The differences are normally distributed

Alternative Hypothesis (Ha): The differences are not normally distributed

Results: Shapiro-Wilk statistic: 0.8629 and P-value: 0.0824

Interpretation: The p value 0.0824 is greater than alpha ( 0.05 ). The differences appear normally distributed, so a paired t-test would be slightly more powerful; the Wilcoxon test remains valid and conservative.

Ranks

RanksNMean RankSum of Ranks
Negative Ranks11.00001.0000
Positive Ranks96.000054.0000
Ties0
Total10

a. Negative Ranks: Knowledge_Score_After < Knowledge_Score_Before

b. Positive Ranks: Knowledge_Score_After > Knowledge_Score_Before

c. Ties: Knowledge_Score_After = Knowledge_Score_Before

Results of the Wilcoxon signed-rank test

Ho: median of the differences in Knowledge Score (Knowledge.Score.After − Knowledge.Score.Before) = 0

Ha: median of the differences in Knowledge Score (Knowledge.Score.After − Knowledge.Score.Before) ≠ 0

ParticularsValue
Hypothesized median (mu, by user)0
V statistic (sum of positive ranks, W+)54.0000
Sum of negative ranks (W-)1.0000
Effective n (non-zero differences)10
Zero differences dropped0
Tied absolute-difference groups3
Z (normal approximation, tie and continuity corrected)2.6606
P value0.0078
Hodges-Lehmann estimate (median difference)10.0000
Lower limit of Conf. interval6.0000
Upper limit of Conf. interval13.0000

Interpretation: The p value 0.0078 was less than alpha (0.05). The result is significant and we reject the null hypothesis. The median of the differences in Knowledge Score is significantly different from 0; knowledge scores were higher after the training (Hodges–Lehmann estimate = 10, 95% CI 6 to 13).

Symmetry check: skewness of the differences is -0.8943, a mild left skew driven by the one farmer whose score fell by 1 point. The signed-rank test assumes roughly symmetric differences, so report the median difference alongside the Hodges–Lehmann estimate; if the asymmetry were strong, the sign test would be a more conservative alternative.

8. Reconciling the Report with the Hand Calculation

8.1 Test Statistic, Z and p-value

StatisticValue
V (=W+)54
Z−2.66 (sign depends on the software’s convention)
p-value (two-tailed)0.0078

V=54 is the sum of positive ranks, the same W+ we found by hand; the hand-calculated W=min(W+,W-)=1 is the same test seen from the other tail, so both give the same p-value. The p-value is below 0.05, so H0 is rejected. The hand-calculated Z with tie and continuity corrections (-2.66) and p=0.0078 agree with the report.

8.2 Hodges–Lehmann Estimate and Confidence Interval

StatisticValue
Hodges–Lehmann estimate (pseudomedian)10
95% confidence intervalapproximately 6 to 13

The Hodges–Lehmann estimate is the median of all 55 pairwise averages (di+dj)/2 with i≤j (the Walsh averages). The interval does not contain zero, which agrees with the rejection of H0. We estimate that training raised the knowledge score by about 10 points, with the plausible range being roughly 6 to 13 points.

Why 10 and not 12? The median of the observed differences is 12, the middle of the ten raw differences. The Hodges–Lehmann estimate uses every pair of differences, so the one discordant value (-1) pulls many of the 55 averages down and the estimate falls to 10. The two answer slightly different questions: the median describes the typical farmer in this sample, while the Hodges–Lehmann estimate is the shift that corresponds to the Wilcoxon test and comes with a confidence interval. Because the differences are mildly left-skewed, the gap between the two is a useful reminder to report both. When the differences are symmetric, the two will be close.

9. Quick Tips for Researchers

  • Use the Wilcoxon test only for paired data. For two independent groups, use the Mann-Whitney U test instead.
  • For more than two related measurements (for example, pre, mid and post), use the Friedman test. For more than two independent groups, use the Kruskal-Wallis test.
  • For single Likert items, use the sign test rather than the Wilcoxon test.
  • Check the normality of the differences (not of the raw before and after scores) when deciding between the paired t-test and the Wilcoxon test.
  • Always report the median, the Hodges–Lehmann estimate and the effect size along with the p-value, and say which method you used for the p-value.
  • Report how many pairs were dropped because of zero differences.
  • If the differences are strongly asymmetric, consider the sign test as a more conservative option.

References

Cohen, J. (1988). Statistical Power Analysis for the Behavioral Sciences (2nd ed.). Lawrence Erlbaum Associates.

Hodges, J. L., & Lehmann, E. L. (1963). Estimates of location based on rank tests. The Annals of Mathematical Statistics, 34(2), 598–611.

Hollander, M., Wolfe, D. A., & Chicken, E. (2014). Nonparametric Statistical Methods (3rd ed.). John Wiley & Sons.

Panse, V. G., & Sukhatme, P. V. (1985). Statistical Methods for Agricultural Workers (4th ed.). Indian Council of Agricultural Research, New Delhi.

Siegel, S., & Castellan, N. J. (1988). Nonparametric Statistics for the Behavioral Sciences (2nd ed.). McGraw-Hill.

Wilcoxon, F. (1945). Individual comparisons by ranking methods. Biometrics Bulletin, 1(6), 80–83.

Tejas S, author

Written by

Tejas S

PhD Scholar, Department of Agricultural Statistics, BA College of Agriculture, Anand Agricultural University, Anand

Connect with Tejas S on LinkedIn