R – How to Simulate a Custom Power Analysis of an LM Model

rsimulationstatistical-power

Following to the recent questions we had here.

I was hopping to know if anyone had come across or can share R code for performing a custom power analysis based on simulation for a linear model?

Later I would obviously like to extend it to more complex models, but lm seems to right place to start.

Best Answer

I'm not sure you need simulation for a simple regression model. For example, see the paper Portable Power, by Robert E. Wheeler (Technometrics , May, 1974, Vol. 16, No. 2). For more complex models, specifically mixed effects, the pamm package in R performs power analyses through simulations. Also see Todd Jobe's post which has R code for simulation.