Opens in a new tab

METHOD GUIDE

Wilcoxon Signed-Rank Test in R
Ties, Zero Differences and Exact p-Values

In R the same call returns an exact p-value or an approximation, and zero differences or tied values decide which one you get. Counting both before the call tells you which p-value to expect and how many pairs the test will actually use.

IN SHORT

What the Signed-Rank Test Ranks and How R Reports It

The Wilcoxon signed-rank test ranks the absolute sizes of the paired differences and compares the rank sum of the positive differences with that of the negative ones, asking whether changes in one direction tend to be larger. It suits ordinal paired outcomes, and continuous ones when the distributional assumptions behind a comparison of mean change are not tenable. To run the Wilcoxon signed-rank test in R, call wilcox.test() on wide data with paired = TRUE, or with Pair() from R 4.4.0, and read V with the method line and any warning. OnlineSPSS, a specialist statistical consultancy for academic, clinical and professional research, carries out and reviews this analysis through an in-house PhD-level statistician.

ANALYSIS SUPPORT

Analysis Support for This Method

Whether the question concerns the direction of paired changes or their mean size decides between a rank-based and a mean-based analysis, and that choice precedes any call in R.

Wilcoxon Signed-Rank Test

The rank-based analysis of paired differences, carried out in R or another program, with the handling of zeros and ties, the effect size and the wording agreed for your data.

Explore Wilcoxon Signed-Rank Test
Paired Samples t-Test

An analysis of the mean of paired differences on a continuous outcome, for when the size of the average change and its interval are what the study needs.

Explore Paired Samples t-Test

BEFORE YOU RUN IT

What to Check Before the Rank Test Runs

Most of what makes a signed-rank result interpretable is visible in the differences themselves, so they are computed and inspected before the test.

Aligned Pairs Each participant has one value per condition, in the same row of a wide file. Misaligned long data produce wrong pairs without any warning, and more than two occasions call for a different test.

Zeros and Ties Expected Pairs with no change give zero differences, which are dropped, and tied absolute differences share ranks. Rating scales and rounded measures produce both, so plan to count them.

Exact or Approximate An exact Wilcoxon p-value in R is computed by default only with fewer than 50 pairs and no zero differences or ties. Otherwise R uses a normal approximation with continuity correction and warns.

Direction or Median Change The test supports a statement that changes in one direction tend to be larger. It speaks of a median change only when the distribution of differences is symmetric, which a plot of them helps judge.

IN R

How to Run the Wilcoxon Signed-Rank Test in R

Base R returns an exact p-value from wilcox.test() only when no zero differences or ties are present, and an approximation otherwise. An exact conditional test for such data is available in the coin package, which is named in the report with its version.

  1. Confirm the design: an ordinal or continuous outcome and two linked measurements per participant.
  2. Arrange wide data with one row per pair, and count the complete pairs.
  3. Compute the differences, count the zeros and the tied absolute values, and plot the differences.
  4. Run the paired wilcox.test in R as wilcox.test(Pair(before, after) ~ 1, data = wide, conf.int = TRUE); the vector form with paired = TRUE also works.
  5. Read V, the p-value, the method in the header and any warning about zeros or ties.
  6. With zeros or ties, consider wilcoxsign_test() in the coin package, and add a rank effect size.

READING THE OUTPUT

V, the Method Line and the Zero and Tie Warnings

The warnings beneath the result matter more here than in most tests, because each one signals that the exact p-value was not computed.

Output element What it tells you What to check
Header line Wilcoxon signed rank exact test, or Wilcoxon signed rank test with continuity correction That the report names the same method
V The sum of the ranks of the positive differences, first minus second That the direction counted as positive is stated
p-value The exact p or the corrected normal approximation, per the header That an approximate p is not described as exact
Warning about zeroes Zero differences were dropped and an exact p was not computed That the number of zero differences is counted and reported
Warning about ties Tied absolute differences prevented an exact p That the approximation is stated as such in the text
Alternative hypothesis A location shift not equal to zero, in wording that differs by version That a one-sided direction was set before the data were seen
(pseudo)median estimate With conf.int = TRUE, the center of the differences under symmetry, with an interval That it is called a pseudo-median, not a median

REPORTING

Wording V, the Pairs Used and the Direction

Zero differences shrink the sample the test actually used, so the count of pairs comes before any reading of V.

Write V = ___, the number of pairs after zero differences were removed (n = ___), the p-value, and whether it is exact or a normal approximation with continuity correction. State how many differences were zero and how many absolute differences were tied. Describe the paired differences with a median and an interquartile range and a plot, and say in words which direction was more common, naming the order of subtraction. Add a matched-pairs rank effect size = ___ with its 95% CI [___, ___], for example from the effectsize package, and name the measure. An interval requested through conf.int refers to the center of the differences under symmetry, so call it a pseudo-median. Give the number of participants enrolled, the pairs complete and the pairs used, so readers can follow every exclusion.

Pairs After ZerosExact or ApproximateZeros and TiesPseudomedian CIRank Effect Size

COMMON MISTAKES

Signed-Rank Write-Ups: Counts, Labels and Signs

Zeros and ties explain several of them, and the R warnings show at a glance which ones apply.

Zero Differences Unreported Pairs with no change are dropped from the ranking. Reporting n as the number enrolled misstates the sample the test used, and a large share of zeros says that most participants did not change.

Approximate p Called Exact When R warns that an exact p cannot be computed, the printed value is an approximation. Calling it exact in the methods misdescribes the test that produced it.

Direction Left Unnamed V counts the positive differences, which are first minus second. Without the order of subtraction, readers cannot tell whether V describes pairs that rose or pairs that fell.

Pseudo-Median Called Median The estimate printed with an interval is a Hodges-Lehmann quantity that equals the median of the differences only under special conditions, so the text names it for what it is.

Missing Pairs Unaccounted A pair with a missing value is removed before any zeros are counted. The n in the sentence should reconcile with the number of participants, and the reason for the loss should be stated.

Rank-Sum Test Run by Mistake Calling wilcox.test(x, y) without paired = TRUE on linked data runs the independent-groups test, and R does not object. The header must read signed rank for the paired analysis.

Signed-rank script finished? Independent Statistical Review checks the method line, the pairs used and the wording of the conclusion before you submit.

Request an Assessment

FREQUENTLY ASKED QUESTIONS

Questions About V and Exact Results in R

V and its warnings carry less information than they seem to, and the first three answers supply what the printed block leaves out.

V is the sum of the ranks of the positive differences, where a difference is the first measurement minus the second. Zero differences are removed before ranking. V depends on the number of pairs, so it is reported with n, and the direction of change is stated in words from the data, not read from V alone.

In its documented default, wilcox.test() falls back on an approximation when zeros or ties are present. The coin package offers wilcoxsign_test() with an exact distribution option, and its zero.method argument sets how zeros are treated, so the setting is stated. Check the documentation of your installed version and name the package.

The effective number is the count of complete pairs minus the zero differences. R prints the p-value but not that count, so compute it from the differences, for example with sum(d != 0), and report it next to the number of zeros and the number of pairs lost to missing values.

Yes. An in-house PhD-level statistician can recount the complete pairs and the zero differences, check the method line against your methods text and confirm the direction you describe, or run the analysis on your data. Once the numbers are settled, the presentation of the result belongs to Results Reporting & Interpretation. The reading of the change in your study remains your own.

Your data and project details are handled confidentially, and project information is not published. Researcher names and institutions are not used publicly without permission. An NDA is available where required and can be arranged before sensitive materials are shared. Read more about confidentiality and data security.

You share your research question, design and relevant materials, such as the dataset or the output you have, and a statistically trained Research Coordinator reviews the request and responds the same day. The analysis, deliverables, timeline and one fixed project fee are then confirmed before any work begins, so the timeline follows from the agreed scope.

Still have a question? Find more answers in our full FAQ.

View All FAQs →

NEXT STEP

Zeros and Ties
in Your Paired Data?

A count of zero differences and a note on ties often change both the method line and the n in the sentence, and an in-house statistician can work through both once the scope of a review is confirmed.

No Commitment Required

Strictly Confidential

Fixed Project Fee

In-House PhD-Level Statisticians

Same-Day Response

Serving Researchers Since 2014