# Model selection in mixed-model context using lmer

Assume I have two factors A and B potentially predicting my outcome Y. Now I would like to test for fixed-effects using likelihood ratio test to find the best model.

fm1 <- lmer(Y~1+A*B+(1|subject))
fm2 <- lmer(Y~1+A+B+(1|subject))
fm3 <- lmer(Y~1+A+(1|subject))
fm4 <- lmer(Y~1+B+(1|subject))
fm5 <- lmer(Y~1+(1|subject))

anova(fm1, fm2, fm3, fm4, fm5)


However I would also like to test for different random-effect specifications.

# all possible random-effects specifications for fm1
fm6 <- lmer(Y~1+A*B+(1+A*B|subject))
fm7 <- lmer(Y~1+A*B+(1+A|subject)+(1+B|subject))
fm8 <- lmer(Y~1+A*B+(1+A|subject))
fm8 <- lmer(Y~1+A*B+(1+B|subject))
fm8 <- lmer(Y~1+A*B+(1|subject))


Is it a valid approach to first detect which fixed-effects specification is most predictive [anova(fm1, fm2, fm3, fm4, fm5)] and then to try different random-effects specification with this model? Or would only the most comprehensive approach be valid in which I specify all possible combinations of fixed- and random-effects to compare all these model to find the best fit?

• I once had a communication with Mike Lawrence on the ez4r mailing list in which he cited Bates & Pinheiro's recommendation to not use likelihood ratio tests for models differing only in their fixed effects: groups.google.com/forum/#!msg/ez4r/GQTEtNziRwE/upOoW_TLExcJ So perhaps your first idea is already bogus, but I am no expert on this. – Henrik Apr 23 '12 at 9:36
• Zuur is working in {nlme} and not {lme4}. It would be really useful to have some input regarding this in the lme4 package! – Dalal_EL_Hanna Nov 27 '13 at 15:09
• Welcome to the site, @Dalal Hanna. This is not an answer to the OP's question. Please only use the "Your Answer" field to provide answers. If you have your own question click the ASK QUESTION at the top & ask it there; then we can help you properly. Since you are new here, you may want to read our about page, which has information for new users. – gung - Reinstate Monica Nov 27 '13 at 15:10