Wilcoxon Signed Rank Test
Calculator
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:
Where:
- = sum of positive ranks
- = sum of negative ranks
Key Assumptions
Practical Example
Step 1: State the Data
Weight measurements before and after treatment (kg):
Subject | Before | After | Difference |
---|---|---|---|
1 | 70 | 68 | +2 |
2 | 80 | 78 | +2 |
3 | 90 | 91 | -1 |
4 | 60 | 58 | +2 |
5 | 85 | 85 | 0 (ignored) |
Step 2: State Hypotheses
- : median difference = 0
- : median difference ≠ 0
Step 3: Assign Ranks
- 1. Order absolute differences in ascending order:
- 2. Assign ranks:
Step 4: Calculate Sums
- = 3 + 3 + 3 = 9 (positive differences)
- = 1 (negative differences)
Step 5: Calculate Test Statistic
Step 6: Draw Conclusion
For (excluding zero difference), at , the critical value is . Since , we fail to reject . There is insufficient evidence to conclude that the treatment had a significant effect on weight.
Code Examples
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)
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}")
Software Implementation Differences
Different statistical software packages report the Wilcoxon Signed-Rank test statistic in distinct ways:
- R(
wilcox.test
): Reports , which is the sum of all positive ranks. - Python(
scipy.stats.wilcoxon
): Reports , where:- is the sum of positive ranks
- is the sum of negative ranks
While these approaches use different test statistics, they lead to equivalent results:
- Both methods yield identical p-values
- The statistics can be converted between formats if needed
- The critical values in this table are based on R's implementation
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!