33 Wilcoxon Signed Rank Test
The Wilcoxon Signed-Rank Test (Frank Wilcoxon, 1945) is a non-parametric statistical hypothesis test used to compare two related samples, matched samples, or repeated measurements on a single sample to assess whether their population mean ranks differ. It is an alternative to the paired Student’s t-test when the data does not meet the assumptions required by the latter, specifically normal distribution of differences.
Purpose
The Wilcoxon Signed-Rank Test is used to compare two related samples, matched samples, or repeated measurements on a single sample to assess whether their population mean ranks differ. It is the non-parametric alternative to the paired t-test.
How it Works
Each pair of observations is first compared, and the differences are ranked based on their absolute values. Next, each difference is assigned a sign (+ or -) based on the direction of the difference.
The test then sums the ranks for the positive differences and the ranks for the negative differences. The test statistic is based on the smaller of these sums.
33.1 Assumptions
The Wilcoxon Signed-Rank Test is based on the following assumptions:
- Paired Data: The data must be paired, coming from the same participants or closely matched subjects.
- Ordinal or Continuous Data: The data should be ordinal, interval, or ratio in nature.
- Symmetry of the Distribution: The distribution of the differences between pairs should be symmetric.
33.2 Hypotheses
The hypotheses for the Wilcoxon Signed-Rank Test are generally framed as follows:
- Null Hypothesis (H₀): The median of the differences between the pairs of observations is zero.
- Alternative Hypothesis (H₁): The median of the differences is not zero.
33.2.1 Formula
The test involves several steps:
- Calculate the difference (\(d\)) between each pair of observations.
- Exclude pairs with no difference (\(d = 0\)).
- Rank the absolute differences, ignoring signs.
- Sum the ranks for the positive differences and the ranks for the negative differences.
- The test statistic (\(W\)) is the smaller of these two sums.
The calculation for \(W\) is: \[ W = \text{min}(W^+, W^-) \] Where:
- \(W^+\) is the sum of ranks for the positive differences.
- \(W^-\) is the sum of ranks for the negative differences.
33.2.2 Interpretation
The significance of the observed \(W\) is evaluated by comparing it to a distribution of \(W\) values expected by chance, which can be obtained from a table of critical values for the Wilcoxon signed-rank test or calculated using an appropriate software function. A small \(W\) value suggests a significant difference between the paired samples.
33.3 Example Problem
Suppose a dietitian wants to determine if a new diet reduces the weight of patients. Weigh-ins are conducted before starting the diet and after one month of being on the diet for 6 patients:
- Weights Before: 200, 220, 180, 195, 210, 230
- Weights After: 190, 215, 175, 185, 205, 225
Hypotheses:
- Null Hypothesis (H₀): The median difference in weight before and after the diet is zero.
- Alternative Hypothesis (H₁): The median difference in weight before and after the diet is not zero.
Calculate Differences and Ranks:
- Calculate differences (Before − After): [10, 5, 5, 10, 5, 5]
- Rank the absolute differences (average ranks used for ties): [5.5, 2.5, 2.5, 5.5, 2.5, 2.5]
- Sum of ranks for positive differences: \(W^+ = 21\) (all six differences are positive, so \(W^- = 0\) and \(W = \min(W^+, W^-) = 0\))
33.4 Wilcoxon Signed-Rank Test using R and Python
This method is crucial for research in fields like medicine and psychology, where matched pairs or repeated measures are common.
Summary
| Concept | Description |
|---|---|
| Foundations | |
| Wilcoxon Signed-Rank Test | A non-parametric test that compares two related samples by ranking the differences between pairs |
| Non-parametric Counterpart of Paired t | Used when paired-t assumptions of normality or interval scale are not met |
| Assumptions | |
| Paired or Matched Data | Each observation in one sample is matched to one in the other, often the same subject measured twice |
| Ordinal, Interval or Ratio Outcome | The outcome must be at least ordinal so that differences can be ranked meaningfully |
| Symmetry of Differences | The differences between pairs should be approximately symmetric around their median |
| Hypotheses | |
| Null Hypothesis | States that the median of the paired differences is zero |
| Alternative Hypothesis | States that the median of the paired differences is not zero |
| Computation | |
| Compute Differences | Subtract one member of each pair from the other to obtain a set of signed differences |
| Rank Absolute Differences | Rank the magnitudes of the differences from smallest to largest, ignoring sign |
| Sum of Positive and Negative Ranks | Sum the ranks for the positive differences and separately for the negative differences |
| Test Statistic W | The test statistic is the smaller of the two rank sums and is compared to a critical value or p-value |
| Handling of Zero Differences | Pairs with a difference of zero are typically dropped before ranking |
| Decision | |
| Decision Rule | Reject H0 when W is small enough to make the observed asymmetry unlikely under the null |
| In R and Python | |
| R via wilcox.test(paired = TRUE) | Use wilcox.test(x, y, paired = TRUE) on two equal-length vectors in R |
| Python via scipy.stats.wilcoxon() | Use scipy.stats.wilcoxon(x, y) on two equal-length sequences in Python |