EZ Statistics

Wilcoxon Signed Rank Test

Calculator

2. Select Columns & Options

Learn More

Wilcoxon Signed Rank Test

Definition

Wilcoxon Signed Rank Test is a non-parametric alternative to the paired t-test. It tests the null hypothesis that the differences between pairs of observations come from a distribution with zero median, without requiring normality.

Formula

Test Statistic:

W=min(W+,W)W = \min(W^+, W^-)

Where:

  • W+W^+ = sum of positive ranks
  • WW^- = sum of negative ranks

Key Assumptions

Paired Observations: Data must be paired
Independence: Pairs must be independent
Continuous Data: Differences should be from continuous distribution
Symmetry: Distribution of differences should be symmetric

Practical Example

Step 1: State the Data

Weight measurements before and after treatment (kg):

SubjectBeforeAfterDifference
17068+2
28078+2
39091-1
46058+2
585850 (ignored)
Step 2: State Hypotheses
  • H0H_0: median difference = 0
  • HaH_a: median difference ≠ 0
  • α=0.05\alpha = 0.05
Step 3: Assign Ranks
  1. 1. Order absolute differences in ascending order:1,2,2,2|-1|, |2|, |2|, |2|
  2. 2. Assign ranks:
    • 1=1rank 1|-1| = 1 \rightarrow \text{rank } 1
    • 2=2mean rank 3  (ranks 2,3,4)|2| = 2 \rightarrow \text{mean rank } 3 \; (\text{ranks } 2,3,4)
Step 4: Calculate Sums
  • W+W^+ = 3 + 3 + 3 = 9 (positive differences)
  • WW^- = 1 (negative differences)
Step 5: Calculate Test Statistic

W=min(W+,W)=min(9,1)=1W = \min(W^+, W^-) = \min(9, 1) = 1

Step 6: Draw Conclusion

For n=4n = 4 (excluding zero difference), at α=0.05\alpha = 0.05, the critical value is 00. Since W=1>0W = 1 \gt 0, we fail to reject H0H_0. There is insufficient evidence to conclude that the treatment had a significant effect on weight.

Code Examples

R
1# Sample data
2before <- c(70, 80, 90, 60, 85)
3after <- c(68, 78, 91, 58, 85)
4
5# Perform the test
6result <- wilcox.test(before, after, paired = TRUE)
7
8# Print results
9print(result)
Python
1from scipy.stats import wilcoxon
2
3# Sample data
4before = [70, 80, 90, 60, 85]
5after = [68, 78, 91, 58, 85]
6
7# Calculate the test
8stat, p_value = wilcoxon(before, after)
9
10# Print results
11print(f"Wilcoxon Signed Rank Test Statistic: {stat}")
12print(f"P-value: {p_value}")

Alternative Tests

Consider these alternatives:

  • Paired t-test: When data is normally distributed
  • Sign Test: When only direction of difference matters

Related Calculators

Paired T-Test Calculator

Mann-Whitney U Test Calculator

One Sample T-Test Calculator

Effect Size Calculator

Help us improve

Found an error or have a suggestion? Let us know!