[R] Statistical Power

Greg Snow Greg.Snow at intermountainmail.org
Tue May 23 18:36:02 CEST 2006


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 at intermountainmail.org
(801) 408-8111
 

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

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

______________________________________________
R-help at 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



More information about the R-help mailing list