I am wondering if there are any methods for calculating sample size in mixed models? I'm using
lmer in R to fit the models (I have random slopes and intercepts).
If you have repeated measures then you should defnintely be able to use the
Also check the
If you don't have repeated measures, then in principle I think you can still use
Liu, G., & Liang, K. Y. (1997). Sample size calculations for studies with correlated observations. Biometrics, 53(3), 937-47.
Diggle PJ, Heagerty PJ, Liang K, Zeger SL. Analysis of longitudinal data. Second Edition. Oxford. Statistical Science Serires. 2002
Edit: Another way is to "correct" for the effect of clustering. In an ordinary linear model each observation is independent, but in the presence of clustering observations are not independent which can be thought of as having fewer independent observations - the effective sample size is smaller. This loss of effectiveness is known as the design effect :
$$ DE = 1 +(m-1)\rho$$ where $m$ is the average cluster size and $\rho$ is the intraclass correlation coefficient (variance partition coefficient). So the sample size obtained through a calculation that ignores clustering is inflated by $DE$ to obtain a sample size that allows for clustering.
For anything beyond the simple 2 sample tests I prefer to use simulation for sample size or power studies. With prepackaged routines you can sometimes see large differences between the results from the programs based on the assumptions that they are making (and you may not be able to find out what those assumptions are, let alone if they are reasonble for your study). With simulation you control all the assumptions.
Here is a link to an example: