Methods & Models Mixed Effect Models
Example - The Model
library(nlme)
MultiLin_Base <- lme(weight ~ Time
*
Diet, # weight as an interaction of time and diet
random = ~+1|Chick, # random effect of Chick
data = ChickWeight)
We now have our model. However, we know that time is a component and we likely have repeated samples here. In these cases, we need to account for
auto-correlation by defining a correlation structure.
MultiLin_Mod <- lme(weight ~ Time
*
Diet, random = ~+1|Chick,
cor=corAR1(), # adding autocorrelation structure since we have repeated measures
data = ChickWeight)
Let’s see which model (basic or the one with auto-correlative structure) performs better:
anova(MultiLin_Base, MultiLin_Mod) # second model is better
## Model df AIC BIC logLik Test L.Ratio p-value
## MultiLin_Base 1 10 5487 5530 -2734
## MultiLin_Mod 2 11 4457 4505 -2217 1 vs 2 1032 <.0001
We clearly prefer the more sophisticated, auto-correlative model and want to see which of its parameters are informative:
anova(MultiLin_Mod) # all parameters should be kept
## numDF denDF F-value p-value
## (Intercept) 1 524 485.8 <.0001
## Time 1 524 1436.8 <.0001
## Diet 3 46 3.5 0.0219
## Time:Diet 3 524 24.9 <.0001
We keep all parameters. Although the inclusion of Diet is not significant, the interaction of Diet and Time is, therefore, both Time and Diet need to stay
irrespective of their significance.
Aarhus University Biostatistics - Why? What? How? 24 / 36