Re: [R] Statistical Power

From: Greg Snow <>
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: 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
(801) 408-8111

-----Original Message-----
[] On Behalf Of Christopher Brown
Sent: Tuesday, May 23, 2006 9:54 AM
Subject: [R] Statistical Power

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

______________________________________________ mailing list PLEASE do read the posting guide!
______________________________________________ mailing list PLEASE do read the posting guide!
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 Please read the posting guide before posting to the list.