#Model-averaging mixed models
library(nlme)
data(Orthodont, package = "nlme")
# Fit model by REML
fm2 <- lme(distance ~ Sex*age + age*Sex, data = Orthodont,
random = ~ 1|Subject / Sex, method = "REML")
# Model selection: ranking by AICc using ML
dd <- dredge(fm2, trace=TRUE, rank="AICc", REML=FALSE)
(attr(dd, "rank.call"))
# Get the models (fitted by REML, as in the global model)
gm <- get.models(dd, 1:4)
# Because the models originate from 'dredge(..., rank=AICc, REML=FALSE)',
# the default weights in 'model.avg' are ML based:
model.avg(gm, method = "NA")
# same result
#model.avg(gm, method = "NA", rank="AICc", rank.args = list(REML=FALSE))
# REML based weights
model.avg(gm, method = "NA", rank="AICc", rank.args = list(REML=TRUE))
Run the code above in your browser using DataLab