# One Sample Wilcoxon effect size

I am struggling with effect size calculations for the Wilcoxon test for one sample in R.

My data:  item1 <- c(1,5,3,4,4,2,3,2,1,4,5,4,3,1)

 dt<- as.data.frame(id=1:14, item1)

My Hypothesis: $$H_0: \theta \le 3 \quad vs. \quad H_1: \theta > 3$$

With this data I get 3 null differences ($$item1-3$$) and thus $$n$$ becomes $$11$$. Hand calculations following Wilcoxon original paper gives $$W=\min(W^+,W^-)=32$$.

If I run the Wilcox_test from package rstatix using

 dt|>rstatix::wilcox_test(item1~1, mu=3, alternative="greater")

I get: $$n=14; w=32; p=0.555$$ (first question, $$n$$, after discounting $$D=item1-3=0$$ should be 11, not 14?

If I run the effect size as

dt|>rstatix::wilcox_effsize(item1~1, mu=3)


I get $$effsize=0.0085$$ with $$n=14$$.

This is $$r=\frac{Z}{\sqrt n}$$ where $$z=\dfrac{W-n*(n+1)/4}{\sigma_w}$$ where $$\sigma_W=\sqrt{\frac{n(n+1)(2 n+1)}{24}-\sum_{i=1}^g \frac{e_i^3-e_i}{48}}$$

My questions:

1. Should the effect size use only the  n<-sum(Di!=0) that is $$11$$, instead of n<-nrow(dt) =$$14$$?
2. If I calculate the rank biserial correlation with rob<-(2 * (W / totalRankSum)) - 1 I get $$rob=-0.030$$ which is close to the $$r=-0.027$$ calculated with $$n=11$$, not $$n=14$$.
3. So, I think that the $$Z$$ and $$r$$ should be calculated with sample size corrected for $$Di=0$$. I can't find a definitive answer in Maciej Tomczak and Ewa Tomczak. The need to report effect size estimates revisited. An overview of some recommended measures of effect size. Trends in Sport Sciences. 2014; 1(21):19-25. They say that $$n$$ should be the $$n$$ used for the $$Z$$ calculation, but say nothing about correcting for null differences....

What do you think? Can you give me a final reference to settle the question of which $$n$$ to use?

• Effect sizes with nonparametric tests are challenging. Commented Mar 29, 2023 at 23:18

My recommendation would be to use the rank biserial correlation coefficient, rather than the r that is the z value divided by the square root of N.

A reference for the calculation is King, B.M., P.J. Rosopa, E.W. and Minium. 2000. Statistical Reasoning in the Behavioral Sciences, 6th. Wiley.

Although it appears you already know how to do this. They show the matched-pairs case, but this can be adapted to the one-sample case.

The r statistic has a few limitations as an effect size statistic. In some cases it won't reach 1 or -1 in cases where we think it should.

If you do use the r statistic, I would decrease N to account for values that equal the designated mu. To, me this seems to give more reasonable results.

There is a question of to deal with these zero-difference observations with the rank biserial correlation coefficient also (or in the Wilcoxon test itself).

I have some examples of these properties with the relevant functions in the rcompanion package, with the caveat that I wrote them.

I can't speak to the rstatix package.

Here, with item2, and mu=3, we would probably expect the effect size to be -1, but it isn't with the r statistic.

library(rcompanion)

item2 = c(1,2,1,2,1,2,1,2,1,2,1,2,1,2)

wilcoxonOneSampleR(item2, mu=3)

###      r
### -0.906


The rank biserial correlation coefficient is -1.

wilcoxonOneSampleRC(item2, mu=3)

### rc
### -1


Here, with zero-difference values, the default for r is to decrease N by the number of zero-difference values.

item3 = c(1,2,1,2,1,2,1,2,1,2,3,3,3,3)

wilcoxonOneSampleR(item3, mu=3)

###      r
### -0.911

###     r
### -0.77


The rank biserial correlation coefficient function also has a verbose option, which may be helpful.

wilcoxonOneSampleRC(item3, mu=3, verbose=TRUE)

### zero.method: Wilcoxon
### n kept = 10
### Ranks plus = 55
### Ranks minus = 0
### T value = 0
###
### rc
### -1


The function also has a zero.method option that can be set to "Pratt" or "none" for different ways to deal with zero-difference values. (See the documentation.)

• Thanks @Sal. I agree, rank biserial is more appropiate then r based on Z. In most cases, both measures agree and since Cohen fave Z, people follow up on it. My problem is which "n" to use. I believe it should be the "n" after removing the null differences, but I can find a suitable reference. Thanks also for the suggestion for the rcompanion... the verbose option and "n kept" is, to me, more correct than the "n" reported by rstatix.
– JPMD
Commented Mar 30, 2023 at 10:56
• Yeah, I don't have a reference for the different ways to handle the null differences. It has been discussed on Stack Exchange in terms of the Wilcoxon signed rank test. You might be able to find some references for the "Wilcoxon" zero method in this context vs. "Pratt". These are mentioned here: ?coin::wilcoxsign_test and here: ?rcompanion::wilcoxonOneSampleRC. Commented Mar 30, 2023 at 14:17
• So I went and took a quick read at Pratt, J. W. (1959). doi: 10.1080/01621459.1959.10501526 ... and I can see Pratt's point... not sure however If I agree. One thing is to have 0 in the data, the other is to have 0 as differences between data... in the first case it makes since to me that you account for the 0 when ranking (I guess that if you sum +1 to the data with zeros, the zero problem goes away). However, Wilcoxon says get rid of 0 for the differences, not for the data (even if we assume mu=0 as Pratt exemplifies ... Or I didn't really get Pratt's point and need to read it again :-)...
– JPMD
Commented Mar 31, 2023 at 12:37
• oh, by the way rcompanion::wilcoxonOneSampleRC(item1, mu=3,zero.method = "Wilcoxon") gives rc=-0.0303 as in my hand calculation (rounded to 3 decimal places).
– JPMD
Commented Mar 31, 2023 at 12:38
• I think, in Pratt the "0"'s mean zero difference, or observation = mu in the one-sample case. The ranking is always done on the differences in these tests. The Pratt method should make sense in most real cases, but it appears to sometimes be squirrely in small-sample toy cases I've played with. Commented Mar 31, 2023 at 19:23