[R-sig-ME] stepwise model selection (of fixed effects only) using AIC?
Steve Taylor
steve.taylor at aut.ac.nz
Mon Jan 7 02:33:52 CET 2013
Hello mixed modellers,
I note that one can fit mixed models and compare them by AIC using anova(), as in example(glmer).
But step() doesn't work on the models produced by glmer() - evidently because they are S4 objects, rather than some more philosophical objection to doing so.
I want to select among combinations of fixed effect components only, as one would do with step(glm()).
My data set consists of two repeated measurements (say, at age 9 and age 11) on each of about 900 people. There are about 8 potential fixed effect covariates that I wish to evaluate, including interaction terms with Age (as a two-level factor). The only random effect I'm assuming is an intercept per participant.
Can anyone help with a way to do this?
Here's my attempt, ignoring the random effect during model selection. Is this a reasonable thing to do?
modeldata1 = subset(modeldata, select= -Participant)
glm0 = glm(Outcome ~ Age, data=modeldata1, family=binomial)
glm1 = glm(Outcome ~ .*Age, data=modeldata1, family=binomial)
scope = list(lower=formula(glm0), upper=formula(glm1))
glm2 = step(glm0, scope, direction='forward')
mm0 = glmer(Outcome ~ (1|Participant) + Age, data=modeldata, family=binomial)
mm2 = update(mm0, formula=update(formula(glm2),'. ~ (1|Participant) + .'))
Interestingly, the results are pretty much the same, from:
library(effects)
plot(allEffects(glm2))
plot(allEffects(mm2))
cheers,
Steve
More information about the R-sig-mixed-models
mailing list