Solved – Sample size calculation Wilcoxon rank-sum test

rsample-size

I am currently writing a seminar paper where I among other things conduct a Wilcoxon rank-sum test. The sample size is very small, so I don't have any significant results. My professor thought it might be interesting to calculate the sample size that would be sufficient for a 5%-signifance level assuming the effect is as strong as I found.

I am a little lost since I have never made such a sample-size calculation. I found the R-package "samplesize" with a function called "n.wilcox.ord" that seems to do the trick but unfortunately I can't make any sense of it (especially the "vector of expected proportions" that is needed there).

It's a within subjects design with a sample size of 22. Statistical power is 0.8 with an alpha of 0.05

Is there maybe another way to do the computation? Any help is strongly appreciated!

Best Answer

I usually turn to simulation for power calculations for the Wilcoxon sign-rank test. I have my own function I use for this. Use it at your own risk, as I don't know that anyone has ever validated it.

You can read the function directly using

source("https://raw.githubusercontent.com/nutterb/StudyPlanning/master/R/sim_wilcoxon.R")

or install the package (I haven't been actively developing it for a couple years) using:

devtools::install_github("nutterb/StudyPlanning")

In order to make it work, you'll need to estimate distributions from each of the groups in your sample. In the example below, I've assumed one group follows a Poisson distribution with a mean of 2.1, and the other follows a Poisson distribution with a mean of 3.53. I've also assumed equal sample sizes. This yields an estimate power of 0.444.

set.seed(123)

sim_wilcoxon(n=22,                 # total sample size
            weights=list(c(1, 1)), # equal sample size per group
            rpois(lambda=2.1),     # distribution of first sample
            rpois(lambda=3.53),    # distribution of second sample
            nsim=1000)

  n_total n1 n2   k alpha power nsim pop1_param  pop2_param pop1_dist pop2_dist
1      22 11 11 0.5  0.05 0.444 1000 lambda=2.1 lambda=3.53     rpois     rpois
Related Question