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.
Asked
Active
Viewed 290 times
2
-
possible duplicate of [Simulation of Logistic Regression Power Analysis - Designed Experiments](http://stats.stackexchange.com/questions/35940/simulation-of-logistic-regression-power-analysis-designed-experiments) – gung - Reinstate Monica Feb 27 '14 at 15:10
1 Answers
4
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.
library(lme4)
library(lmerTest)
simulateFixedEffect <- function(model, ecotype, time, id, B){
Tvalue=rep(0, B)
set.seed(781)
for(b in 1:B){
s1 <- drop(simulate(model))
ms <- lmer(s1$sim_1 ~ ecotype * time + (time | id))
Tvalue[b] <- anova(ms)[[6]][3]
}
return(Tvalue)
}
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")
grid()
}
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)

conjugateprior
- 19,431
- 1
- 55
- 83

Any Camargo
- 61
- 4