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!

  • $\begingroup$ You can change the required sample size by changing $\alpha$ or $\beta$ (1 - power) or both. Leaving $\alpha$ at 0.05 and increasing the power to 0.9 will increase the required sample size. $\endgroup$ May 24 '17 at 21:36
  • $\begingroup$ Thank you for your quick answer, Michael. Unfortunately I really don't know how to calculate the required sample size. As my question stated, I am having trouble with the required arguments ("vector of expected proportions") of the "n.wilcox.ord" function. Maybe you know an alternative way of calculating the sample size? $\endgroup$
    – Benjamin
    May 27 '17 at 17:16

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


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


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.


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

  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
  • $\begingroup$ Thank you for your answer and your function. So what I did was estimating a suitable distribution for the samplez via 'fitdistr' and manipulated n until I reached a power of ~0.8. sim_wilcoxon(n=600, weights=list(c(1, 1)), rpois(lambda=3.27), rpois(lambda=2.86), nsim=20000) n_total n1 n2 k alpha power nsim pop1_param pop2_param pop1_dist pop2_dist 1 600 300 300 0.5 0.05 0.78905 20000 lambda=3.27 lambda=2.86 rpois rpois Do you think this is appropriate? $\endgroup$
    – Benjamin
    May 27 '17 at 19:18
  • $\begingroup$ Yup, that works. I would also run the simulation under your actual sample size so that you can report the actual power of your experiment. $\endgroup$
    – Benjamin
    May 28 '17 at 0:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.