How do you perform a power analysis for linear mixed model using R? I measure area of five groups of plants across time. Each group of plants grow under two treatments. I have 12 replicates for each plant. I have fitted a lme with plant group and treatment as fix effects and the replicates as random effect. How can I go from that to the actual calculation? I have found tools for ANOVAs and MANOVAs but not for lme. Thanks.


1 Answer 1


This is one way to perform power analysis using lmer. I have created a simulated data set using different functions. Here I report how I could perform the actual simulation.


simulateFixedEffect <- function(model, ecotype, time, id, B){
  Tvalue=rep(0, B)
  for(b in 1:B){
    s1 <- drop(simulate(model))
    ms <- lmer(s1$sim_1 ~ ecotype * time + (time | id))
    Tvalue[b] <- anova(ms)[[6]][3]

plotValue <- function(Fvalue, alpha=0.05){
  mean(Fvalue > alpha)
  hist(Fvalue, 30, prob=T, xlab="", ylab="", main="")
  x <- seq(0, 15, 0.1)
  lines(x, df(x,1,80), col="red")

time <- (subdata$time)
    gclass <- as.factor(subdata$gclass)
id <- subdata$id
    growth <- subdata$growth

m1 <- lmer(growth ~ gclass * time + (time | id))
Tvalue <- simulateFixedEffect(m1,gclass, time, id, 10)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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