UK-based online statistics and data analysis support for USA, UK, and international clients. No exams, no impersonation, no fabricated data.

Nonparametric paired-sample location test

Wilcoxon Signed Rank Test: 7 Steps, Formula and Worked Example

The Wilcoxon signed rank test is a magnitude-sensitive nonparametric method for two related measurements or one sample of differences. This complete guide explains what the test measures, when to use it, how zeros and tied ranks are handled, how W and V differ across software, and how to reproduce a verified G1-versus-G3 grade analysis in Python, R, SPSS and Excel.

Paired or matched dataSigned absolute ranksZeros and ties auditedEffect size includedPython + R + SPSS + Excel
All pairs649
Minimum W25,595.5
Two-sided p5.57 × 10⁻²⁴
Rank-biserial0.5255
Quick answer

Final grades were systematically higher than first-period grades.

For 649 paired student records, the difference was defined as G3 − G1. There were 344 positive changes, 120 negative changes, and 185 zero differences. After excluding zeros, the positive absolute-rank sum was W+ = 82,284.5 and the negative sum was W− = 25,595.5. The two-sided minimum statistic was W = 25,595.5, with tie-adjusted z = −10.099 and p = 5.5689 × 10⁻²⁴. The matched-pairs rank-biserial correlation was 0.5255, and the sample median increase was 1 grade point.

Interpretation: the paired-difference distribution is not centered symmetrically around zero. The direction and ranked magnitude of the evidence favor higher G3 values. This conclusion is about paired change; it is not an independent-groups comparison and should not be described as a Wilcoxon rank sum result.
1

What does the Wilcoxon signed rank test measure?

A paired test that combines the direction and ranked magnitude of nonzero differences.

The Wilcoxon signed rank test begins with paired differences rather than with two separate samples. Every student, patient, machine, site or matched unit contributes one difference. The method then ranks the absolute nonzero differences and restores their signs, allowing larger changes to contribute more than smaller changes while avoiding the normality requirement of the paired t test.

The formal target

Let D = Y − X denote a paired difference. The Wilcoxon signed rank test null is most accurately expressed as a difference distribution that is symmetric around zero. Under a continuous symmetric location-shift model, that statement is equivalent to a zero median and zero pseudomedian shift. The distinction matters because the method uses both signs and magnitudes; it is not merely a count of observations above and below zero.

For the worked example, X is the first-period grade G1 and Y is the final grade G3. A positive D means that the final grade exceeds the earlier grade. Because the same student supplies both values, the pairing removes stable between-student differences from the comparison and focuses directly on within-student change.

What the test does not measure

It is not the Wilcoxon rank sum test, Mann–Whitney U test, or a comparison of two independent groups. It is also not automatically a test of means, and the phrase “test of medians” is incomplete unless the paired-difference distribution is reasonably symmetric. It does not show that every individual improved, nor does a small p-value establish that the change is educationally important.

The scientific result should therefore combine the Wilcoxon signed rank test inference with the median paired change, the counts of positive, negative and zero changes, and an effect size. This prevents a very large sample from turning a statistically detectable but trivial change into an exaggerated conclusion.

Key distinction: the paired design is part of the method, not an optional formatting choice. Analyzing G1 and G3 as independent samples would discard the row-by-row relationship and answer a different question. Review paired-means inference, the sign test, and Wilcoxon rank sum test when choosing among related procedures.
2

When should you use the Wilcoxon signed rank test?

Use it when the design is paired and the ranked magnitudes of within-pair changes are scientifically meaningful.

A paired Wilcoxon signed rank test is appropriate for before-and-after measurements, two conditions applied to the same subjects, matched case-control pairs, or a one-sample comparison of observations with a hypothesized value. The decision should follow the research design and estimand, not simply a failed normality test.

Confirm pairing

Each value in the first measurement must correspond to exactly one value in the second.

Create differences

Define the subtraction direction before viewing the result, such as G3 − G1.

Check the scale

Differences must be orderable, and their absolute magnitudes must be meaningful enough to rank.

Assess symmetry

A simple location-shift interpretation requires a reasonably symmetric nonzero-difference distribution.

Plan inference

Choose the zero method, exact or approximate reference, continuity correction, and effect size.

Strong applications

Pretest and posttest scores from the same students.
Pain ratings before and after treatment for the same patients.
Matched measurements from paired devices, sites or specimens.
A one-sample signed-rank comparison with a meaningful benchmark.
A robustness analysis when paired differences are non-normal but reasonably symmetric.

Use another method when

The groups are independent; use rank sum or another independent-groups method.
There are three or more related conditions; consider the Friedman test or a repeated-measures model.
Only direction is trustworthy; the sign test may be more defensible.
The outcome is nominal or binary; use a paired categorical procedure such as McNemar’s test.
Pairs are clustered within higher-level units; use a design-aware model or clustered rank method.
3

Wilcoxon signed rank test assumptions

Nonparametric does not mean assumption-free.

The most important Wilcoxon signed rank test assumptions concern correct pairing, independence between pairs, an orderable response, meaningful paired differences, and symmetry when the result is interpreted as a location or median shift. Ties and zeros do not invalidate the analysis, but they change its calculation and reference distribution.

Correctly matched pairs

The two values in each row must refer to the same observational unit or to a defensibly matched pair. A row mismatch creates artificial differences and can overwhelm the rank calculation.

Independence between pairs

One student’s difference should not determine another student’s difference. Family, classroom, school or repeated-session clustering requires additional modeling.

Ordered measurement

The response must support ordering, and the sizes of the differences must carry enough meaning for absolute differences to be ranked.

Symmetric differences

For a clean zero-median location-shift interpretation, the nonzero difference distribution should be approximately symmetric around its center.

Randomization basis

Generalization depends on random sampling, random assignment, or a clearly defined observational population. The test itself cannot repair selection bias.

Transparent zeros and ties

Zero differences and tied absolute differences must be handled by a stated rule. Software defaults are not interchangeable.

Symmetry is not normality. A difference distribution may be heavy-tailed and non-normal yet reasonably symmetric. Conversely, a strongly one-sided or multi-modal distribution can violate the location-shift interpretation even if a normality test is not significant. Use a histogram, frequency table, quantiles and subject-matter reasoning rather than relying on a single diagnostic p-value.

The current differences range from −11 to +11. Most observations are at −1, 0, +1 or +2, but a few large changes appear in both tails. The median is +1, the first quartile is 0 and the third quartile is +1. This structure supports a clear directional conclusion, while the sensitivity section checks whether the result depends on magnitude, zero treatment or a few influential pairs.

4

Hypotheses for paired and one-sample signed-rank tests

State the difference direction and the population claim before calculating ranks.

Two-sided paired hypothesis

H0: the distribution of D = G3 − G1 is symmetric about 0

Under a symmetric location-shift model, this is commonly summarized as a population median or pseudomedian paired change of zero.

H1: the distribution of D is not symmetric about 0

The alternative allows either systematically higher G3 or systematically lower G3.

Directional alternatives

Improvement

H₁: D is shifted above 0.

Decline

H₁: D is shifted below 0.

Two-sided

H₁: D differs from 0 in either direction.

A one-sided hypothesis must be prespecified. Choosing “greater” after observing that G3 is higher invalidates the intended error rate. The subtraction order must also be explicit: reversing G3 − G1 to G1 − G3 reverses the signs, swaps W+ and W−, and changes the direction of a one-sided alternative.

Applied statement for the worked data

The analysis tests whether the paired student-grade differences G3 − G1 are centered symmetrically around zero. The observed median difference is +1. Positive changes occur in 344 rows and negative changes in 120 rows. More importantly for the Wilcoxon signed rank test method, the positive ranked magnitude is 82,284.5 compared with 25,595.5 for negative changes. This produces overwhelming evidence against the zero-centered null.

5

Wilcoxon signed rank test formula and seven calculation steps

The full calculation explains W, V, ties, zeros, z and the p-value.

The Wilcoxon signed rank test formula is simple only after the data preparation rules are made explicit. The calculation must preserve pairs, define the sign direction, remove or otherwise treat zeros, rank tied absolute differences with midranks, and distinguish the positive rank sum from the minimum two-sided statistic.

Step 1: calculate paired differences

di = yi − xi

For this example, dᵢ = G3ᵢ − G1ᵢ. Positive values represent higher final grades.

Step 2: identify zero differences

Under the conventional Wilcox rule, dᵢ = 0 observations are removed from the rank calculation. They remain important descriptive information. Here 185 of 649 pairs are unchanged, leaving n = 464 nonzero differences.

Step 3: rank the nonzero absolute differences

Ri = rank(|di|)

Tied absolute differences receive their average rank. The 276 absolute differences of one receive rank 138.5, while the 119 absolute differences of two receive rank 336.0.

Step 4: restore the signs

Si = sign(di)Ri

A positive difference contributes a positive rank and a negative difference contributes a negative rank.

Step 5: sum positive and negative ranks

W+ = ∑RiI(di>0),   W = ∑RiI(di<0)

In the worked analysis, W+ = 82,284.5 and W− = 25,595.5. Their sum is n(n+1)/2 = 107,880, verifying that every nonzero rank is allocated exactly once.

Step 6: define the reported statistic

W = min(W+, W) = 25,595.5

Many two-sided implementations report the smaller sum. R commonly reports V = W+, while MATLAB and SPSS may label a positive-rank statistic or standardized result. Always name the convention.

Step 7: standardize with tie adjustment

E(W+) = n(n+1)/4 = 53,940
Var(W+) = n(n+1)(2n+1)/24 − ∑(t3−t)/48

The summation runs over tie groups in the nonzero absolute differences. For these data, Var = 7,877,035.875 and SE = 2,806.605757.

z = [W − E(W)]/SE = −10.099210

Using the minimum statistic produces a negative standardized value. The two-sided probability is 2Φ(−|z|) = 5.568917 × 10⁻²⁴ without continuity correction.

Continuity correction: moving the statistic 0.5 toward the null mean gives z = −10.099032 and p = 5.579042 × 10⁻²⁴. The numerical difference is negligible here, but the correction setting should still be reported because software defaults differ.
Absolute differenceFrequency among nonzero pairsAssigned midrankRole in the calculation
1276138.5Most common magnitude; dominates the number of ranked observations.
2119336.0Second-most common magnitude and a major part of W+.
342416.5Moderate paired changes.
49442.0Less frequent, higher-ranked changes.
5–1118449.5–463.5Tail observations with high individual ranks but low frequency.
6

Worked example: G1 versus G3 student grades

A fully auditable paired analysis with 649 rows.

Research scenario and variables

The source data contain the same students’ first-period grade G1 and final grade G3. The observational unit is the student row, so the measurements are paired. The research question is whether final grades are systematically shifted relative to first-period grades.

RoleVariableMeaning
Earlier measurementG1First-period numeric grade.
Later measurementG3Final numeric grade.
Paired differenceG3 − G1Positive means final grade is higher.
Valid paired rows649Rows with both values present.

Descriptive context

G1 has mean 11.3991, median 11 and standard deviation 2.7453. G3 has mean 11.9060, median 12 and standard deviation 3.2307. The paired difference has mean 0.5069, median 1 and standard deviation 1.8208. Its first and third quartiles are 0 and 1.

These summaries already suggest improvement, but they do not incorporate the pairing in an inferential calculation. The signed-rank test asks whether the direction and ranked magnitude of the within-student differences are consistent with a zero-centered symmetric distribution.

Positive changes34453.0% of all pairs
Negative changes12018.5% of all pairs
Unchanged18528.5% of all pairs
Median change+1G3 minus G1
Difference G3 − G1CountInterpretive note
−11 to −318Large declines are uncommon but must be inspected.
−217Moderate decline.
−185Most frequent negative change.
0185Excluded from conventional signed ranks and reported separately.
+1191Most frequent positive change.
+2102Substantial contribution to positive rank sum.
+3 to +1151Larger improvements, including a small number of extremes.
Worked-calculation checkpoint: after removing zeros, 464 ranks remain. Their sum must equal 464 × 465 / 2 = 107,880. The workbook obtains 82,284.5 + 25,595.5 = 107,880 exactly, confirming correct ranking and sign allocation.
7

Wilcoxon signed rank test results and effect size

Statistical significance, practical magnitude and software conventions reconciled.

Primary inference

p = 5.57 × 10⁻²⁴

Reject H₀

The tie-adjusted normal approximation places the observed minimum rank sum more than ten standard errors from its null expectation. The evidence for a positive shift from G1 to G3 is overwhelming.

Calculation audit

W+82,284.500
W− / minimum W25,595.500
Expected rank sum53,940.000
Tie-adjusted variance7,877,035.875
Standard error2,806.605757
z statistic−10.099210

Matched-pairs rank-biserial

rrb = (W+ − W−)/(W+ + W−) = 0.525482

This effect size compares positive and negative ranked evidence. A positive value means the ranked changes favor G3, and a magnitude above 0.5 is substantial in this sample.

Standardized r

r = |z|/√nnonzero = 0.468844

This widely reported standardized measure uses the 464 nonzero pairs. State the denominator because using all 649 pairs would yield a different number.

Original-unit change

Median(G3 − G1) = +1

The grade-point scale remains essential. The effect sizes describe ranked dominance, while the median communicates a typical observed change in the original units.

EvidenceResultWhat it adds
Signed-rank normal approximationz = −10.099, p = 5.5689 × 10⁻²⁴Magnitude-sensitive inference with tie adjustment.
Continuity-corrected approximationp = 5.5790 × 10⁻²⁴Shows the decision is insensitive to the optional correction.
Exact two-sided sign testp = 4.1673 × 10⁻²⁶Direction-only sensitivity analysis; zeros excluded.
Rank-biserial correlation0.5255Quantifies positive versus negative ranked magnitude.
Median paired difference+1 grade pointReturns the finding to the observed measurement scale.
Do not report only “p < .001.” The exact displayed value is far smaller and is reproducible from the tie-adjusted calculation. More importantly, report the 185 zeros, the positive and negative rank sums, and an effect size so the result is not reduced to sample-size-driven significance.
8

Wilcoxon signed rank test in Python

SciPy calculation, zero handling, tie-aware approximation and chart interpretation.

The Wilcoxon signed rank test in Python is available through scipy.stats.wilcoxon. For auditable work, create and round the paired differences explicitly, document zero_method, choose the approximation method, and inspect the returned statistic convention before comparing it with R or SPSS.

Python / SciPyimport numpy as np
import pandas as pd
from scipy import stats

df = pd.read_csv("dataset.csv")
d = (df["G3"] - df["G1"]).dropna().to_numpy()
d = np.round(d, 12) # prevents artificial near-zero differences

result = stats.wilcoxon(
d,
zero_method="wilcox",
correction=False,
alternative="two-sided",
method="approx"
)

print(f"W minimum = {result.statistic:.6f}")
print(f"z = {result.zstatistic:.6f}")
print(f"p = {result.pvalue:.12e}")
# W minimum = 25595.500000
# z = -10.099210
# p = 5.568917452888e-24

Why pass the difference vector?

Passing a precomputed difference vector makes the subtraction order visible and allows deliberate rounding before equality and zero checks. Floating-point subtraction can create tiny nonzero values that should be zero, causing inconsistent ranks. That issue is less visible when two vectors are passed directly.

Zero-method sensitivity

The conventional wilcox result is the primary analysis. With these data, the Pratt method gives statistic 47,795.5 and p = 8.44 × 10⁻²⁶, while z-split gives statistic 56,398.0 and p = 2.30 × 10⁻²⁵. All reject strongly, but they answer slightly different zero-handling implementations.

Python primary metrics for the Wilcoxon signed rank test

Python chart 1: Primary metrics

The primary-metrics chart combines the minimum signed-rank statistic, p-value, nonzero and zero-pair counts, matched-pairs rank-biserial correlation, median paired difference, and the positive and negative rank sums. The very large positive-rank total—82,284.5 versus 25,595.5—shows that increases from G1 to G3 were not only more frequent but also carried substantially greater ranked magnitude.

Python signed paired differences for the Wilcoxon signed rank test

Python chart 2: Signed paired differences

The signed-difference distribution is concentrated at 0, +1, and +2 grade points. There are 185 unchanged pairs, 344 positive differences, and 120 negative differences. The plot also reveals a small number of large positive and negative changes, which is why a magnitude-sensitive signed-rank analysis gives more information than a sign test based only on direction.

Python positive and negative rank sums for the Wilcoxon signed rank test

Python chart 3: Positive and negative rank sums

The decomposition verifies the central arithmetic identity. The nonzero absolute ranks sum to 107,880.0; 82,284.5 belongs to positive differences and 25,595.5 belongs to negative differences. The reported two-sided statistic is the smaller sum, W = 25,595.5, while some software instead prints the positive sum as V or W+.

Python difference-frequency audit for the Wilcoxon signed rank test

Python chart 4: Difference-frequency audit

The frequency display tracks every observed value of G3 − G1. A +1 change occurred 191 times and a +2 change occurred 102 times, compared with 85 changes of −1 and 17 changes of −2. The tails include a few changes as large as ±11, so the assumptions section explains why symmetry and influential pairs must be checked rather than assumed.

Python verified result summary for the Wilcoxon signed rank test

Python chart 5: Verified result summary

The final summary reconciles all reported quantities: W = 25,595.5, 464 nonzero pairs, 185 zero pairs, rank-biserial correlation = 0.5255, median paired change = 1 grade point, W+ = 82,284.5, and W− = 25,595.5. The normal approximation gives z = −10.099 and p = 5.57 × 10⁻²⁴, decisively rejecting symmetry around zero.

9

Wilcoxon signed rank test in R

Base R uses the same paired differences but labels its statistic differently.

The Wilcoxon signed rank test in R is performed with wilcox.test() and paired = TRUE. With ties and zeros, set exact = FALSE for the large-sample reference and state whether the continuity correction is used.

R / statsdf <- read.csv("dataset.csv")

d <- round(df$G3 - df$G1, 12)
fit <- wilcox.test(
d,
mu = 0,
alternative = "two.sided",
exact = FALSE,
correct = FALSE,
conf.int = TRUE
)

fit
# R commonly reports V = the positive rank sum = 82284.5

Why R and Python show different statistics: Python’s two-sided SciPy result displays the smaller rank sum, 25,595.5. Base R generally displays V, the positive rank sum, 82,284.5. The two values are complementary because they sum to 107,880. A correct cross-software audit reconciles the definitions rather than declaring one program wrong.
R effect-size calculationd_nz <- d[d != 0]
ranks <- rank(abs(d_nz), ties.method = "average")
W_plus <- sum(ranks[d_nz > 0])
W_minus <- sum(ranks[d_nz < 0])
r_rank_biserial <- (W_plus - W_minus) / (W_plus + W_minus)

c(W_plus = W_plus,
W_minus = W_minus,
rank_biserial = r_rank_biserial,
median_difference = median(d))

R primary metrics for the Wilcoxon signed rank test

R chart 1: Primary metrics

The primary-metrics chart combines the minimum signed-rank statistic, p-value, nonzero and zero-pair counts, matched-pairs rank-biserial correlation, median paired difference, and the positive and negative rank sums. The very large positive-rank total—82,284.5 versus 25,595.5—shows that increases from G1 to G3 were not only more frequent but also carried substantially greater ranked magnitude.

R signed paired differences for the Wilcoxon signed rank test

R chart 2: Signed paired differences

The signed-difference distribution is concentrated at 0, +1, and +2 grade points. There are 185 unchanged pairs, 344 positive differences, and 120 negative differences. The plot also reveals a small number of large positive and negative changes, which is why a magnitude-sensitive signed-rank analysis gives more information than a sign test based only on direction.

R positive and negative rank sums for the Wilcoxon signed rank test

R chart 3: Positive and negative rank sums

The decomposition verifies the central arithmetic identity. The nonzero absolute ranks sum to 107,880.0; 82,284.5 belongs to positive differences and 25,595.5 belongs to negative differences. The reported two-sided statistic is the smaller sum, W = 25,595.5, while some software instead prints the positive sum as V or W+.

R difference-frequency audit for the Wilcoxon signed rank test

R chart 4: Difference-frequency audit

The frequency display tracks every observed value of G3 − G1. A +1 change occurred 191 times and a +2 change occurred 102 times, compared with 85 changes of −1 and 17 changes of −2. The tails include a few changes as large as ±11, so the assumptions section explains why symmetry and influential pairs must be checked rather than assumed.

R verified result summary for the Wilcoxon signed rank test

R chart 5: Verified result summary

The final summary reconciles all reported quantities: W = 25,595.5, 464 nonzero pairs, 185 zero pairs, rank-biserial correlation = 0.5255, median paired change = 1 grade point, W+ = 82,284.5, and W− = 25,595.5. The normal approximation gives z = −10.099 and p = 5.57 × 10⁻²⁴, decisively rejecting symmetry around zero.

10

Wilcoxon signed rank test in SPSS

Menu steps, syntax, ranks table and result interpretation.

The Wilcoxon signed rank test in SPSS is available through the related-samples nonparametric procedures. The output should be read from the ranks table outward: verify negative ranks, positive ranks and ties before interpreting the standardized statistic and asymptotic significance.

Legacy-dialog menu path

  1. Choose Analyze → Nonparametric Tests → Legacy Dialogs → 2 Related Samples.
  2. Move G3 and G1 into a paired test field.
  3. Select Wilcoxon.
  4. Run the analysis and verify the subtraction direction shown in the ranks labels.

The negative-ranks row identifies cases where the first named variable is below the second, so variable order changes the labels even though a two-sided p-value is unchanged.

Modern related-samples path

  1. Choose Analyze → Nonparametric Tests → Related Samples.
  2. Place G3 and G1 in the fields list.
  3. Customize the analysis and request the Wilcoxon matched-pairs signed-rank test.
  4. Review hypotheses, test summary and pair details.

Use exact or Monte Carlo settings only when appropriate and available. A large tied dataset generally relies on asymptotic inference.

SPSS syntaxNPAR TESTS
/WILCOXON = G3 WITH G1 (PAIRED)
/MISSING ANALYSIS.
SPSS output itemExpected worked-example valueInterpretation
Negative ranksN = 120; sum = 25,595.5G3 below G1.
Positive ranksN = 344; sum = 82,284.5G3 above G1.
TiesN = 185G3 equals G1; no signed contribution.
ZApproximately −10.099Standardized rank-sum departure; sign depends on software convention.
Asymp. Sig. (2-tailed)< .001Reject the zero-centered paired null.
SPSS reporting error to avoid: do not copy the “mean rank” column as an effect size. Mean ranks are intermediate summaries. Report the positive and negative rank sums, z, p, the median paired change, and a separately calculated rank-biserial or standardized effect size.
11

How to do the Wilcoxon signed rank test in Excel

A formula-driven worksheet with correct zero exclusion and tied midranks.

Excel does not have a dedicated Wilcoxon signed rank test command. A correct worksheet must rank nonzero absolute paired differences, not the original observations, and must subtract the zero count from ascending ranks when a full-range RANK.AVG formula includes zeros.

Column / cellPurposeExcel formula
A2:A650G1 valuesRaw paired measurement.
B2:B650G3 valuesRaw paired measurement.
C2Difference=B2-A2
D2Absolute difference=ABS(C2)
E2Nonzero midrank=IF(C2=0,"",RANK.AVG(D2,$D$2:$D$650,1)-COUNTIF($C$2:$C$650,0))
F2Signed rank=IF(C2=0,0,SIGN(C2)*E2)
H2Positive rank sum=SUMIF($C$2:$C$650,">0",$E$2:$E$650)
H3Negative rank sum=SUMIF($C$2:$C$650,"<0",$E$2:$E$650)
H4Minimum W=MIN(H2,H3)
H5Nonzero n=COUNTIF($C$2:$C$650,"<>0")
H6Null mean=H5*(H5+1)/4

Tie-adjusted variance

Create a small helper table containing each distinct nonzero absolute difference and its frequency. If the frequencies are in K2:K11, use:

=H5*(H5+1)*(2*H5+1)/24
-SUMPRODUCT(K2:K11^3-K2:K11)/48

The result is 7,877,035.875. Then compute =(H4-H6)/SQRT(H7) for z and =2*NORM.S.DIST(-ABS(H8),TRUE) for the two-sided p-value.

Effect size and validation

Rank-biserial:
=(H2-H3)/(H2+H3)

Rank-sum identity:
=H2+H3-H5*(H5+1)/2

The identity check must equal zero. The rank-biserial formula returns 0.525482. The supplied workbook separates raw inputs, row-level ranks, calculations, diagnostics and reporting for auditability.

Extreme p-values: spreadsheets may display zero when a probability underflows or when an unstable subtraction such as 2*(1-NORM.S.DIST(ABS(z),TRUE)) is used. Calculate the lower tail directly with 2*NORM.S.DIST(-ABS(z),TRUE). The exact sign-test p-value is about 4.17 × 10⁻²⁶, not literally zero.
12

Wilcoxon signed rank test in MATLAB, SAS and Stata

Equivalent paired commands with statistic-definition cautions.

MATLAB

[p,h,stats] = signrank(G3,G1, ...
'tail','both', ...
'method','approximate');

p
stats.signrank
stats.zval

MATLAB’s signrank tests the paired difference and returns a positive-rank statistic plus a z value for approximate inference. Check the variable order before interpreting a directional alternative.

SAS

data paired;
set student;
diff = G3 - G1;
run;

proc univariate data=paired;
var diff;
run;

PROC UNIVARIATE provides signed-rank inference for a one-sample variable, so compute the paired difference first. Report the signed-rank statistic, p-value, zeros and original-unit summary.

Stata

signrank G3 = G1

generate diff = G3 - G1
summarize diff, detail

Stata reports the positive, negative and zero ranks plus the standardized result. Pairing is row-based, so verify the data structure before running the command.

13

Wilcoxon signed rank test versus related methods

Choose by design, estimand, symmetry and measurement scale.

MethodDesignMain targetUses magnitude?Key caution
Wilcoxon signed rankOne sample or two paired measurementsZero-centered symmetric difference / paired location shiftYes, through absolute ranksSymmetry is needed for a simple median-shift interpretation.
Sign testOne sample or pairedProbability of positive versus negative differencesNoLess information and often less power, but weaker magnitude assumptions.
Paired t testPairedPopulation mean paired differenceYes, raw valuesSensitive to outliers and relies on mean-based sampling behavior.
Wilcoxon rank sumTwo independent groupsIndependent-sample stochastic/location comparisonRanks pooled observationsNot valid for paired rows.
Friedman testThree or more related conditionsRepeated-measures rank differencesWithin-block ranksOmnibus result usually needs adjusted follow-up comparisons.
Paired permutation testPairedUser-defined statistic under exchangeability or sign-flip nullDepends on statisticThe permutation scheme and target statistic must match the hypothesis.
Signed rank versus rank sum: the names sound similar because both trace to Wilcoxon, but the mechanics are different. Signed rank ranks absolute within-pair differences. Rank sum pools observations from independent groups and ranks the observations themselves. The data structure determines the test.
14

Diagnostics, zeros, ties and sensitivity analysis

A defensible result includes checks beyond the p-value.

Difference-distribution diagnostics

Plot G3 − G1 directly rather than separate histograms only.
Report positive, negative and zero counts.
Compare left and right tails around the median.
Inspect extreme pairs and verify their source values.
Check whether subgroups show qualitatively different change patterns.

For these data, the central distribution favors +1 and +2 changes, while both tails contain a small number of large differences. The conclusion remains extremely strong under direction-only and alternative zero-method analyses.

Method sensitivity results

Analysisp-value
Wilcox zeros removed5.5689 × 10⁻²⁴
Wilcox + continuity correction5.5790 × 10⁻²⁴
Pratt zero method8.4397 × 10⁻²⁶
Zero ranks split2.2975 × 10⁻²⁵
Exact sign test4.1673 × 10⁻²⁶

Every reasonable implementation rejects. The stability of the conclusion is more informative than selecting whichever method produces the smallest p-value.

Missing pairs

Use complete paired records for the primary analysis and report how many rows were excluded. Do not rank an observation whose partner is missing.

Rounding

Round computed differences to measurement precision before identifying zeros or ties. Tiny floating-point artifacts can incorrectly change the effective sample size.

Multiple outcomes

If many outcomes or time contrasts are tested, control familywise error or false discovery rate and distinguish planned from exploratory comparisons.

Large-sample warning: with 464 nonzero pairs, very small p-values are possible for modest systematic changes. Statistical significance should therefore be paired with the +1 median change, effect sizes, distributional display and substantive context.
15

How to interpret and report the Wilcoxon signed rank test

APA-style wording, result table and common mistakes.

APA-style worked result

A Wilcoxon signed-rank test was used to compare paired final grades (G3) with first-period grades (G1) for 649 students. The paired difference was defined as G3 − G1. Of the 649 pairs, 344 were positive, 120 were negative and 185 were zero; the conventional Wilcox calculation therefore ranked 464 nonzero differences. Final grades were higher in ranked location, with a median paired increase of 1 grade point, W = 25,595.5, z = −10.10, p = 5.57 × 10⁻²⁴, matched-pairs rank-biserial correlation = .525. The zero-centered symmetric-difference null was rejected.

Report elementRecommended value or wordingReason
Pair definitionG3 paired with G1 within studentEstablishes dependence structure.
Subtraction directionG3 − G1Defines positive and negative ranks.
Total and effective n649 total; 464 nonzeroZeros are excluded under the primary rule.
Original-unit summaryMedian change = +1Communicates practical magnitude.
Rank counts344 positive, 120 negative, 185 tiesShows the pattern underlying W.
Statistic conventionMinimum W = 25,595.5Prevents confusion with R’s V = 82,284.5.
Standardized resultz = −10.099Documents the approximation.
Probabilityp = 5.5689 × 10⁻²⁴More informative than only p < .001.
Effect sizeRank-biserial = 0.5255Quantifies ranked direction and magnitude.

Correct language

“The paired differences were shifted above zero.”
“Positive ranked changes exceeded negative ranked changes.”
“The median observed paired change was +1.”
“The result was statistically significant with a substantial rank-biserial effect.”

Language to avoid

“Every student improved.”
“The means were significantly different” unless a paired mean test was performed.
“The groups were independent.”
“W = 82,284.5” without identifying that this is the positive rank sum or R’s V.

Eight interpretation checkpoints before publishing a result

1. Name the design. A Wilcoxon signed rank test result begins with the pairing statement. Readers should know whether the same people were measured twice, whether units were deliberately matched, or whether one sample was compared with a benchmark. Without that information, the Wilcoxon signed rank test can be mistaken for the independent-samples rank sum procedure.

2. Define the direction. State whether the difference is later minus earlier, treatment minus control, or observed minus target. The sign of the ranks and any one-sided Wilcoxon signed rank test conclusion depend on this choice. Reversing the subtraction swaps positive and negative rank sums even though a two-sided Wilcoxon signed rank test p-value remains equivalent.

3. Separate total pairs from ranked pairs. The current analysis contains 649 complete pairs, but the conventional Wilcoxon signed rank test ranks only 464 nonzero differences. Reporting both values prevents readers from assuming that 185 unchanged observations disappeared because of missing data. A transparent Wilcoxon signed rank test table should list positive, negative and zero counts.

4. Identify the statistic convention. One program may label the positive rank sum V, another may label the smaller rank sum W, and a third may emphasize Z. A cross-software Wilcoxon signed rank test comparison is correct only after those conventions are reconciled. For this Wilcoxon signed rank test, 82,284.5 and 25,595.5 are complementary, not contradictory.

5. Report magnitude in two languages. The Wilcoxon signed rank test effect can be described on the original grade scale with a median change of +1 and on the ranked scale with rank-biserial correlation 0.5255. A strong Wilcoxon signed rank test report includes both so statistical evidence and practical meaning are visible together.

6. Document ties and zeros. This Wilcoxon signed rank test contains many tied absolute differences because grades are integers. Midranks and a tie-adjusted variance are therefore essential. The zero rule—Wilcox, Pratt or z-split—must also be named because a Wilcoxon signed rank test statistic is not fully reproducible without it.

7. Match the conclusion to the null. The Wilcoxon signed rank test rejects a zero-centered symmetric-difference model; it does not prove that every pair changed in the same direction. In the current Wilcoxon signed rank test, 120 students had lower G3 values and 185 had no change, even though the overall ranked evidence strongly favors improvement.

8. Preserve the audit trail. A publishable Wilcoxon signed rank test should allow another analyst to reconstruct differences, ranks, rank sums, variance, z, p and effect size. The downloadable workbook and software reports make this Wilcoxon signed rank test result verifiable rather than presenting an isolated p-value.

16

Wilcoxon signed rank test downloads

Reports and workbook for verification, teaching and reproducibility.

Reproducibility check: all four resources should agree on 649 paired rows, 185 zeros, 464 nonzero differences, positive rank sum 82,284.5, negative rank sum 25,595.5, median difference +1 and rank-biserial correlation 0.525482. Software may display a complementary statistic but should not change the inference.
17

Method documentation and related statistical guides

How the calculation was verified and where to continue learning.

Documentation checked

The method description and software guidance were reconciled with current documentation for SciPy’s wilcoxon, base R’s wilcox.test, IBM SPSS related-samples and NPAR TESTS procedures, and MATLAB’s signrank. These references agree that the paired difference is central, absolute differences are ranked, signs determine rank sums, and symmetry is needed for the standard location interpretation.

The public article avoids treating software defaults as universal. Exact versus approximate inference, continuity correction, zero handling and statistic labels differ across implementations.

18

Wilcoxon signed rank test FAQs

Answers to interpretation, calculation, software and reporting questions.

What is the Wilcoxon signed rank test?

Wilcoxon signed rank test: The Wilcoxon signed rank test is a nonparametric procedure for one sample of differences or two related measurements. It ranks the nonzero absolute differences, restores their signs, and tests whether the difference distribution is symmetric about zero. For paired data, it is often used when a paired t test is not suitable and the difference scale is at least ordinal with meaningful magnitudes.

When should the Wilcoxon signed rank test be used?

Wilcoxon signed rank test: Use it for two measurements from the same units, matched pairs, or a one-sample comparison with a specified value when the research question concerns a systematic location shift and the paired differences are reasonably symmetric. It is not appropriate for independent groups, nominal outcomes, or repeated designs with more than two conditions.

Is the Wilcoxon signed rank test a test of medians?

Wilcoxon signed rank test: Only under an appropriate symmetric difference distribution can the null be expressed as a zero median or zero pseudomedian shift. In general, the formal null concerns symmetry of the paired-difference distribution around zero. Calling it only a median test hides the symmetry requirement and the use of ranked magnitudes.

What is W in the Wilcoxon signed rank test?

Wilcoxon signed rank test: W may mean the smaller of the positive and negative rank sums in a two-sided calculation, the positive rank sum, or a software-specific signed-rank statistic. In this analysis W+ = 82,284.5, W− = 25,595.5, and the minimum statistic is W = 25,595.5. The report must name the convention instead of presenting an unlabeled W.

What is V in R wilcox.test output?

Wilcoxon signed rank test: For a paired or one-sample signed-rank test, R commonly labels the sum of positive ranks as V. With differences defined as G3 − G1, V is 82,284.5 here. That differs from SciPy’s two-sided statistic of 25,595.5 because SciPy reports the smaller rank sum, yet the p-values and substantive conclusion agree.

How are zero differences handled?

Wilcoxon signed rank test: The conventional Wilcox method removes zero differences before ranking. This analysis therefore ranks 464 nonzero pairs and reports 185 zeros separately. Pratt retains zeros in the ranking framework but excludes their signed contribution, while z-split divides zero ranks between signs. These choices can change the statistic and standard error, so the zero method must be stated.

How are tied absolute differences handled?

Wilcoxon signed rank test: Equal absolute differences receive midranks. Here many grade changes have absolute values of one or two, creating substantial ties. The normal-approximation variance is therefore tie-adjusted. Exact no-tie critical-value tables are not appropriate for this large tied dataset.

What are the assumptions of the Wilcoxon signed rank test?

Wilcoxon signed rank test: The pairs must be correctly matched and independent of other pairs; the response must be orderable; the paired differences must be meaningful; and a location-shift interpretation requires an approximately symmetric difference distribution. Random sampling or random assignment is also needed for broad population inference.

Does the Wilcoxon signed rank test require normality?

Wilcoxon signed rank test: No. It does not require normally distributed paired differences. It does require enough structure for the signed ranks to have a location interpretation, particularly symmetry for a simple median-shift statement. Severe asymmetry may make a sign test, permutation approach, robust model, or direct quantile analysis more suitable.

What is the difference between the signed rank and rank sum tests?

Wilcoxon signed rank test: The signed rank test analyzes paired observations or one sample of differences. The rank sum test analyzes two independent groups and is equivalent to the Mann–Whitney U framework. Confusing them changes both the data structure and the null hypothesis.

What is the difference between the signed rank test and the sign test?

Wilcoxon signed rank test: The sign test uses only whether each nonzero difference is positive or negative. The signed rank test also uses ranked absolute magnitudes, which can improve power when the symmetry assumption is reasonable. In this dataset, the sign test also rejects strongly, but it does not use the information contained in the sizes of the changes.

How is the Wilcoxon signed rank p-value calculated?

Wilcoxon signed rank test: After zeros are removed and tied absolute differences receive midranks, the positive and negative rank sums are compared with their null expectation. For a large tied sample, a tie-adjusted normal approximation is used. Here E(W+) = 53,940, SE = 2,806.606, z = −10.099 under the minimum-statistic convention, and the two-sided p-value is 5.57 × 10⁻²⁴.

Should a continuity correction be used?

Wilcoxon signed rank test: A continuity correction moves the observed rank sum by 0.5 toward its null expectation before standardization. It is optional and software defaults differ. In this example the uncorrected p-value is 5.5689 × 10⁻²⁴ and the corrected value is 5.5790 × 10⁻²⁴, so the conclusion is unchanged.

How is effect size reported for the Wilcoxon signed rank test?

Wilcoxon signed rank test: The matched-pairs rank-biserial correlation is especially interpretable because it compares positive and negative ranked evidence: (W+ − W−)/(W+ + W−). It equals 0.5255 here, indicating a substantial tendency toward higher G3 than G1. A standardized r based on |z|/√n_nonzero is 0.4688 and may be reported as a supplementary effect size.

How should the test be reported in APA style?

Wilcoxon signed rank test: Name the paired variables and direction of subtraction, give the number of pairs and zeros, describe the median change, identify the statistic convention, report z and the exact displayed p-value, and include an effect size. A concise example is provided in the reporting section.

Can the Wilcoxon signed rank test be done in Excel?

Wilcoxon signed rank test: Yes, but Excel has no dedicated built-in command. A transparent worksheet must calculate paired differences, exclude zeros, assign midranks to nonzero absolute differences, sum positive and negative ranks, apply the tie-adjusted variance, and calculate the normal-approximation p-value. The supplied workbook performs and audits these steps.

What should be done when the paired-difference distribution is strongly asymmetric?

Wilcoxon signed rank test: Do not automatically describe the Wilcoxon signed rank test result as a median comparison. Inspect the difference histogram, quantiles, and influential pairs. Depending on the research goal, use the paired sign test, a permutation test targeting a clearly defined statistic, a robust paired model, or a bootstrap interval for the median change.

What conclusion follows from this worked example?

Wilcoxon signed rank test: Final grades G3 tended to exceed first-period grades G1. The sample median change was +1, positive changes outnumbered negative changes 344 to 120, and positive ranked magnitude was much larger. The Wilcoxon signed rank test rejected the zero-centered null, W = 25,595.5, z = −10.099, p = 5.57 × 10⁻²⁴, with rank-biserial correlation 0.5255.

↑ Back to top