[R] R packages for power analysis

Greg Snow 538280 at gmail.com
Thu Aug 28 23:35:22 CEST 2014


While there are tools that claim to compute power for tests beyond
what you find in the pwr package, I don't like to use them because
either I don't agree with the assumptions that they make, or I don't
know what assumptions are being made (and therefore I don't know
whether I agree with them or not).  Once you are beyond the basics
there are a lot more assumptions/conditions to think about.  A tool
that you can just plug a few values into will need to make some
assumptions for you.  To do a proper power analysis without having the
assumptions made for us you need a tool that is more a programming
language than a plug-and-chug toy.  Luckily R is such a programming
language.  You can compute power using simulation with just the main R
packages.  Here is some sample code for a simulation to compute power
for the Mann-Whitney (also called the Wilcoxon) test:

simfun <- function(n1=25, n2=n1, mu1=5, mu2=mu1) {
x1 <- rexp(n1, 1/mu1)
x2 <- rexp(n2, 1/mu2)
wilcox.test(x1,x2)$p.value
}

out <- replicate(10000, simfun(mu1=5,mu2=8))
hist(out)
abline(v=0.05,col='red')
mean(out <= 0.05)

Change the means/sample sizes/etc. and rerun for additional information.

On Thu, Aug 28, 2014 at 1:29 PM, varin sacha <varinsacha at yahoo.fr> wrote:
> Dear all,
>
> I do know very well the pwr packages from Stéphane Champely.
> I would have known if somebody knows others packages for power analysis ?
> I think here more about the calculation of the power analysis of the nonparametric tests like the mann whitney or the kruskall wallis.
>
> Best Regards,
>
> Sacha
>         [[alternative HTML version deleted]]
>
>
> ______________________________________________
> 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.
>



-- 
Gregory (Greg) L. Snow Ph.D.
538280 at gmail.com



More information about the R-help mailing list