[R] How to compute the power of a wilcoxon test?

peter dalgaard pdalgd at gmail.com
Thu Sep 15 17:01:56 CEST 2011

On Sep 15, 2011, at 15:47 , tn85 wrote:

> Hello All,
> I posted a similar question before, but the direction was driven to whether
> my case is suitable for a wilcoxon test. After research about the
> appropriateness, I am pretty sure that a wilcoxon test is the right tool for
> my case. But how to compute the power of the test is still an unanswered
> question bothering me.
> The basic stats of my two paired samples are:
> mean1 = 0.0032,   sd1 = 0.012
> mean2 = 0.00042, sd2 = 0.0016
> sample size = 366
> Could anyone help? Thank you in advance.

Thing is, you can't really do that. Nonparametic tests are only distribution-free under the null hypothesis. For power, you need the distribution of the test statistic under the alternative.

First: Do you really mean "paired"? If so, there would seem to be some information missing, namely the magnitude of the correlation. Also, do you really mean that the sd's differ by a factor of 10?? (And, if those are empirical quantities, don't do power calculations at all).

Assuming that you have two independent samples of size 366, and parameters as above, you might do 

> pval <- replicate(1000, wilcox.test(rnorm(366,.0032,.012), rnorm(366,.00042,.0016))$p.value)
> summary(pval)
     Min.   1st Qu.    Median      Mean   3rd Qu.      Max. 
0.0000000 0.0000004 0.0000185 0.0064520 0.0003877 0.8997000 
> sum(pval < .05)
[1] 979

suggesting a power of around 98%. Adjust as necessary.   

> --
> View this message in context: http://r.789695.n4.nabble.com/How-to-compute-the-power-of-a-wilcoxon-test-tp3815616p3815616.html
> Sent from the R help mailing list archive at Nabble.com.
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

Peter Dalgaard, Professor
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Email: pd.mes at cbs.dk  Priv: PDalgd at gmail.com

More information about the R-help mailing list