Cross Validated is a question and answer site for people interested in statistics, machine learning, data analysis, data mining, and data visualization. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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. Thanks.

share|improve this question
up vote 4 down vote accepted

I'm not sure you need simulation for a simple regression model. For example, see the paper Portable Power. 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.

share|improve this answer
The Portable Power link is broken. If somebody can update the link, that would be great. Thx. – Brian P Sep 27 '14 at 18:20

Here are a few sources of simulation code in R. I'm not sure if any specifically address linear models, but perhaps they provide enough of an example to get the gist:

There's another couple of examples of simulation at the following sites:

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.