I've been looking at mixed effects modelling using the lme4 package in R. I'm primarily using the lmer command so I'll pose my question through code that uses that syntax. I suppose a general easy question might be, is it OK to compare any two models constructed in lmer using likelihood ratios based on identical datasets? I believe the answer to that must be, "no", but I could be incorrect. I've read conflicting information on whether the random effects have to be the same or not, and what component of the random effects is meant by that? So, I'll present a few examples. I'll take them from repeated measures data using word stimuli, perhaps something like Baayen (2008) would be useful in interpreting.

Let's say I have a model where there are two fixed effects predictors, we'll call them A, and B, and some random effects... words and subjects that perceived them. I might construct a model like the following.

m <- lmer( y ~ A + B + (1|words) + (1|subjects) )

(note that I've intentionally left out data = and we'll assume I always mean REML = FALSE for clarity's sake)

Now, of the following models, which are OK to compare with a likelihood ratio to the one above and which are not?

m1 <- lmer( y ~ A + B + (A+B|words) + (1|subjects) )
m2 <- lmer( y ~ A + B + (1|subjects) )              
m3 <- lmer( y ~ A + B + (C|words) + (A+B|subjects) )
m4 <- lmer( y ~ A + B + (1|words) )                 
m5 <- lmer( y ~ A * B + (1|subjects) )   

I acknowledge that the interpretation of some of these differences may be difficult, or impossible. But let's put that aside for a second. I just want to know if there's something fundamental in the changes here that precludes the possibility of comparing. I also want to know whether, if LRs are OK, and AIC comparisons as well.

  • 1
    $\begingroup$ Related: stats.stackexchange.com/questions/117497. See also bbolker.github.io/mixedmodels-misc/…. $\endgroup$
    – amoeba
    Commented Apr 23, 2018 at 20:25
  • $\begingroup$ (I noticed you removed the [hypothesis-testing] tag that I added previously. Well, up to you, but I think it's appropriate: likelihood ratio test is clearly a hypothesis testing procedure, and [mixed-model]+[hypothesis-testing] is IMHO an informative tag combination, see stats.stackexchange.com/questions/tagged/…) $\endgroup$
    – amoeba
    Commented Apr 24, 2018 at 20:41
  • $\begingroup$ Edited to remove "test" from LR. LRs can be interpreted without test and it makes it more parallel to AICs and follows my real intent better. Thanks for pointing that out. $\endgroup$
    – John
    Commented Apr 25, 2018 at 2:30

2 Answers 2


Using maximum likelihood, any of these can be compared with AIC; if the fixed effects are the same (m1 to m4), using either REML or ML is fine, with REML usually preferred, but if they are different, only ML can be used. However, interpretation is usually difficult when both fixed effects and random effects are changing, so in practice, most recommend changing only one or the other at a time.

Using the likelihood ratio test is possible but messy because the usual chi-squared approximation doesn't hold when testing if a variance component is zero. See Aniko's answer for details. (Kudos to Aniko for both reading the question more carefully than I did and reading my original answer carefully enough to notice that it missed this point. Thanks!)

Pinhiero/Bates is the classic reference; it describes the nlme package, but the theory is the same. Well, mostly the same; Doug Bates has changed his recommendations on inference since writing that book and the new recommendations are reflected in the lme4 package. But that's more than I want to get into here. A more readable reference is Weiss (2005), Modeling Longitudinal Data.

  • $\begingroup$ models m2 and m4 or m1 and m3 couldn't be compared with the likelihood ratio test. They are not nested models. $\endgroup$
    – Macro
    Commented Sep 25, 2011 at 4:15
  • $\begingroup$ Oops, thanks for catching that, @Macro ! See edit. $\endgroup$ Commented Sep 25, 2011 at 4:31
  • $\begingroup$ The question was just about comparing the models to model m, not to each other. But nevertheless, are you saying that the AIC comparisons can be made even when not nested? Answers to this question appear to contradict that. $\endgroup$
    – John
    Commented Sep 25, 2011 at 15:52
  • $\begingroup$ @John, I read those answers but missed where it discusses AIC and non-nested. I'm pretty sure it's fine, but can you give me a more precise pointer to that point in the answers? $\endgroup$ Commented Sep 25, 2011 at 19:26
  • $\begingroup$ I downvoted the answer, because you are wrong (or at least misleading) about the applicability of the likelihood ratio test. $\endgroup$
    – Aniko
    Commented Sep 26, 2011 at 18:41

You have to be careful using likelihood-ratio tests when evaluating whether a variance component is 0 (m vs m-m4), because the typical chi-square approximation does not apply. The reason is that the null-hypothesis is $\sigma^2=0$, and it is on the boundary of the parameter space, so the classical results do not apply.

There is an entire theory of the distribution of LRT in these situations (see, for example, Self and Liang, 1987 [1]), however it quickly becomes messy. For the special case of only one parameter hitting the boundary (eg, m vs m2), the likelihood ratio has a $\frac 12 \chi^2_1 + \frac 12 \chi^2_0$ distribution, which in practice means that you have to halve your p-value based on $\chi^2_1$.

However, as @Aaron stated, many experts do not recommend doing a likelihood ratio test like this. Potential alternatives are the information criteria (AIC, BIC, etc), or bootstrapping the LRT.

[1] Self, S. G. & Liang, K. Asymptotic properties of maximum likelihood estimators and likelihood ratio tests under nonstandard conditions J. Amer. Statist. Assoc., 1987, 82, 605-610.

  • 1
    $\begingroup$ Thanks for the LR info. I hadn't really thought about the LR boundary issue when making the models for the example. I just noticed that it's unclear in your answer if your recommendations apply to simple cases like just comparing models with different fixed effects (ML estimated of course). $\endgroup$
    – John
    Commented Apr 23, 2018 at 20:17
  • $\begingroup$ No, this issue only comes up when testing the variance components, not the fixed effects. $\endgroup$ Commented Jun 6, 2018 at 14:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.