Solved – R: coin::wilcoxsign_test() distribution = “exact”

rwilcoxon-signed-rank

In a repeated measure design, I have two measurements for one variable for N=5 subjects. I am interested in assessing whether the distribution of the differences between the two measurements is symmetrical around zero. For this reason, I am performing a Wilcoxon Signed-Rank test with wilcox.test() in R.

However, due to a zero in my differences, I am warned in R that I cannot get an exact p-value. The warning I get is:

Warning message:
In wilcox.test.default(x, y, paired = TRUE) :
cannot compute exact p-value with zeroes

More specifically, what I am understanding is that a continuity correction will be applied to my p-value since my T statistic will be compared against a normal approximation of the T distribution. Am I understanding this correctly? I am understanding that similarly this happens also when there are ties in the difference values.

Moreover, due to the low numerosity of my sample, I understand that approximating the T distribution to a normal one is not the ideal solution, so I am shifting to the wilcoxsign_test() function from the coin package. By using the distribution = "exact" argument, it seems to me that the wilcoxsign_test() function will compare the T statistic computed on my data against the T distribution computed by permuting all my data. Is this correct?
Moreover, handling of ties (and zeroes?) will be carried out according to the Pratt (1959) method (default). Am I correct?

Finally, does the distribution = "asymptotic" argument correspond to perform a normal approximation?

Best Answer

There are several questions here. I will attempt to assemble some the comments and my own thoughts into an answer. A caveat here is that I'm not entirely familiar with the programming of these functions, so there may be misconceptions in the following answer.

Note that this question pertains to the paired or one-sample tests.

Warning. The warning message from wilcox.test doesn't imply that the test results are invalid. It merely means what it says: The test can't compute an exact p-value when there are zero differences. Instead it will remove the zeros and compute the p-value by asymptotic approximation. The following two calls give the same result:

wilcox.test(c(0,1,2,3,4), exact=F)

wilcox.test(c(1,2,3,4), exact=F

Continuity correction: The continuity correction is applied only when the p-value is computed by asymptotic approximation. So the following give the same result:

wilcox.test(c(1,2,3,4), exact=T, correct=F)

wilcox.test(c(1,2,3,4), exact=T, correct=T)

but the following give different results:

wilcox.test(c(1,2,3,4), exact=F, correct=F)

wilcox.test(c(1,2,3,4), exact=F, correct=T)

I'm pretty sure the wilcoxsign_test function never applies the continuity correction.

Handling of zero differences: As mentioned above, when there are zero differences, the wilcox.test function removes those zeros, and uses the asymptotic approximation for the p-value.

The wilcoxsign_test function can compute an "exact" p-value when there are zero differences. For example,

wilcoxsign_test(c(0,0,0,0,0)~c(0,1,2,3,4), distribution="exact").

The wilcoxsign_test function can handle zero differences in two ways, so that the following give different results: Pratt and Wilcoxon:

wilcoxsign_test(c(0,0,0,0,0)~c(0,1,2,3,4), distribution="approximate", zero.method="Pratt")

wilcoxsign_test(c(0,0,0,0,0)~c(0,1,2,3,4), distribution="approximate", zero.method="Wilcoxon")

But I don't think these methods differ if distribution="exact" is used. I'm not sure.

With wilcoxsign_test, I think using distribution="asymptotic" and zero.method="Wilcoxon" will result in the same handling as would wilcox.test, so that the following two give the same result:

wilcoxsign_test(c(0,0,0,0,0)~c(0,1,2,3,4), distribution="asymptotic", zero.method="Wilcoxon")

wilcox.test(c(0,1,2,3,4), exact=F, correct=F)