# Re: [R] Statistical Power

From: Greg Snow <Greg.Snow_at_intermountainmail.org>
Date: Wed 24 May 2006 - 02:36:02 EST

For other than the basic situations I generally use simulation to estimate power. Follow these basics steps:

Write a function that takes as input the things that you may want to change in estimating power (sample size, effect size, standard deviations, ...). Inside the function generate random data based on the inputs and your study design and computes the p-value that you are interested in and returns that p-value.

Then use the function replicate or sapply to run this function a bunch of times (I usually do about 1,000) and save the p-values in a vector. The estimated power is then mean(outvec < 0.05) (or whatever your alpha level is).

The website: http://maven.smith.edu/~nhorton/R/ has an example of simulating power for a mixed effects model (though it uses a loop rather than replicate).

Hope this helps,

```--
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.snow@intermountainmail.org
(801) 408-8111

-----Original Message-----
From: r-help-bounces@stat.math.ethz.ch
[mailto:r-help-bounces@stat.math.ethz.ch] On Behalf Of Christopher Brown
Sent: Tuesday, May 23, 2006 9:54 AM
To: R-help@stat.math.ethz.ch
Subject: [R] Statistical Power

How can I compute a power analysis on a multi-factor within-subjects
design?

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide!
http://www.R-project.org/posting-guide.html

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
```
Received on Wed May 24 03:58:40 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Wed 24 May 2006 - 04:10:18 EST.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.