Published Updated

R’s exact Wilcoxon test can return p-values outside the valid range

R’s exact Wilcoxon test returned negative p-values and a value above 1 on a zero-difference input; we reported it with three independent exact-arithmetic checks.

Earlier version. nomue was an earlier version of SciGround. Its verification capabilities are now part of SciGround; earlier publications, packages, and records keep the nomue name as a historical record.

Current status

R Core confirmed the report and committed a tail-accuracy correction in R-devel r90641 on October 5, 2026. R Bugzilla PR#19144 is CLOSED with resolution FIXED.

Martin Maechler reproduced the result on x86_64 and confirmed the exact reference on October 3. Kurt Hornik first added a range guard in r90638; Maechler’s subsequent correction avoids the inaccurate tail subtraction for both one-sample and two-sample calculations. The r90641 source change and regression test are public. R NEWS credits Tasuku Kobayashi’s reports and Ahmed Sattar Jabbar’s suggestion.

This completes the upstream report’s confirmed-and-fixed disposition. Availability in a released R version has not been verified in this status review; the original observations below describe the affected historical builds.

What we observed

A deterministic input of 100 integers, including exactly one zero difference, caused the one-sample exact path of wilcox.test() to return finite p-values outside the valid interval from 0 to 1. The calls completed without a warning and reported the method as Wilcoxon signed rank exact test.

AlternativeR resultExact reference in binary64
two.sided-7.5495165674510645e-152.5853625172819263e-18
greater-3.7747582837255322e-151.2926812586409632e-18
less1.00000000000000381.0

A p-value is a probability. A negative p-value or a value greater than 1 is outside its mathematical range. For the upper-tail call, the exact p-value is small but strictly positive; it is not zero.

How we checked it

We reproduced the same displayed values in R 4.6.0, R 4.6.1, and an official R-devel build from SVN trunk revision r90451. The R-devel build ran under Rscript --vanilla on x86_64-pc-linux-gnu. Repeated calls were bitwise identical.

Three separately implemented exact-arithmetic lineages agreed on the conditional, zero-preserving signed-rank distribution. R and the exact computations also agreed on the signed-rank statistic, 4755. The disagreement was in the probability calculation, not the observed statistic.

Reporter-side numerical diagnostic

For this input, the floating-point mass function constructed by .dsignrank() summed to 1.0000000000000038. The cumulative probability used by .psignrank() had the same value. Taking its complement therefore produced the negative upper-tail result, and doubling that complement produced the negative two-sided result.

R Core subsequently confirmed the cancellation problem: subtracting a probability close to one loses the small upper tail. The r90641 correction computes the requested tail directly rather than relying on that subtraction.

Why clamping is insufficient

Restricting the final output to the interval from 0 to 1 would hide the invalid negative value, but it would turn the upper-tail result into zero. The exact upper-tail probability is approximately 1.2927e-18, so that guard would still return the wrong numerical answer.

Summing the floating upper tail directly kept the result inside the valid range, but it remained 26 representable floating-point steps from the correctly rounded exact value. This historical diagnostic did not establish correctly rounded output. R Core’s later r90641 correction addresses the cancellation; its regression test allows a relative error of 2e-14 for the small tails rather than claiming correct rounding.

Scope

The report concerns the one-sample exact Wilcoxon signed-rank path with a zero difference in the tested R 4.6.x and R-devel versions. It does not show that every wilcox.test() calculation is affected, and it does not estimate how often ordinary research workflows reach this numerical regime.

R 4.4.3 returned in-range values for the same calls through older behavior that removed the zero and used an asymptotic path. That comparison uses a different calculation path and is not evidence that the new exact result is correct after a simple fallback.

The upstream report is confirmed and fixed in R-devel. This status does not establish correctly rounded output for every input or availability in a released R version.

Relation to verification

This case illustrates why a range check and an accuracy check are different. A guard can make a number look valid while discarding a strictly positive tail. A bounded verification result therefore needs to say both which property was checked and what remains unestablished.

The report does not establish that nomue Protocol currently supports Wilcoxon verification, and it is not comparative evidence that nomue improves research-agent performance.

Public evidence