Wilcoxon Signed-Rank Test Calculator (For Paired Samples)

Group 1 (e.g., Before) (n=0)

Group 2 (e.g., After) (n=0)

Your results will be displayed here.

Understanding the Wilcoxon Signed-Rank Test

The Wilcoxon Signed-Rank Test is a non-parametric statistical test used to determine if there is a significant difference between two related samples or repeated measurements on a single sample. It serves as an alternative to the paired-samples t-test when the assumption of normally distributed differences is not met. The test is used for "within-subjects" designs, such as comparing scores before and after an intervention.

When to Use the Wilcoxon Signed-Rank Test

This test is appropriate when you have two sets of scores that are related or paired. For example, you might use it to compare the anxiety levels of individuals before and after a therapy program, or to compare the performance of employees on two different tasks. The key requirement is that the data comes in matched pairs and the differences between these pairs are what you wish to analyze.

Assumptions of the Wilcoxon Signed-Rank Test

Interpreting the Results

The test works by calculating the differences between each pair, ranking the absolute values of these differences, and then summing the ranks of the positive and negative differences. The output includes:


Frequently Asked Questions (FAQ)

Q1: How is the W statistic calculated manually?

The calculation follows these steps:

  1. For each pair, calculate the difference: \(d_i = \text{After}_i - \text{Before}_i\).
  2. Discard any pairs where the difference is zero. Let the remaining number of pairs be \(n\).
  3. Take the absolute value of each non-zero difference, \(|d_i|\).
  4. Rank these absolute differences from 1 (smallest) to \(n\) (largest). Handle ties by assigning the average rank.
  5. Sum the ranks corresponding to the original positive differences. This is \(W^+\).
  6. Sum the ranks corresponding to the original negative differences. This is \(W^-\).
  7. The test statistic, \(W\), is the smaller of the two sums: \(W = \min(W^+, W^-)\).

Q2: What is the difference between the Wilcoxon Signed-Rank Test and the Mann-Whitney U Test?

The main difference lies in the study design they are used for.

Choosing the wrong test can lead to incorrect conclusions.

Q3: How is the Z-approximation calculated for this test?

For larger sample sizes (e.g., \(n > 20\)), a normal approximation with a Z-score is used to find the p-value. The Z-score is calculated as:

$$ Z = \frac{W - \mu_W}{\sigma_W} $$

Where:

Q4: What are the null and alternative hypotheses?

The hypotheses for the two-tailed test are:

How to Do This in Statistical Software

The weight-loss example data used by default in this calculator (Group 1 "before" vs. Group 2 "after") can be reproduced directly in the following tools.

RStudio

R's built-in wilcox.test() function performs the paired Wilcoxon test directly:

before <- c(110, 115, 120, 122, 125, 128, 130, 131, 135, 140)
after  <- c(105, 110, 112, 125, 124, 120, 122, 128, 130, 132)

wilcox.test(after, before, paired = TRUE, correct = TRUE)

Note: R disables the exact p-value automatically when ties are present and falls back to the normal approximation (matching this calculator), unless you set exact = FALSE explicitly.

Python

scipy.stats.wilcoxon runs the same test, with the normal approximation available via mode='approx':

from scipy.stats import wilcoxon

before = [110, 115, 120, 122, 125, 128, 130, 131, 135, 140]
after  = [105, 110, 112, 125, 124, 120, 122, 128, 130, 132]

stat, p = wilcoxon(after, before, mode='approx', correction=True)
print(stat, p)

SPSS

Analyze → Nonparametric Tests → Legacy Dialogs → 2 Related Samples. Move your two paired variables into the Test Pair(s) List, and make sure Wilcoxon is checked under Test Type, then click OK. SPSS reports the ranks table (positive, negative, and tied ranks), the Z-statistic, and the two-tailed p-value.

JASP

T-Tests → Paired Samples T-Test. Move your two variables into the Paired Variables box, then under Tests, uncheck Student and check Wilcoxon signed-rank instead. JASP outputs the W statistic and p-value directly, alongside an option to show descriptive plots of the paired differences.

Related Statistical Calculators