anova.merMod recalculates models using REML = FALSE, where to find the reference?

StackOverflow https://stackoverflow.com/questions/21523472

  •  06-10-2022
  •  | 
  •  

Question

I have been using the anova.merMod function from lme4 package to obtain p-values for fixed effects through likelihood ratio tests for a scientific publication (most reviewers still demand p-values in my field). I noticed that the anova.merMod function recalculates the lmer functions using REML = FALSE (see the example below), which is an incredibly nice feature forcing less acquainted users to do the test right. However, I have been trying to read most of the documentation for lme4 package and cannot find that a notation of this feature (for instance, see ?anova.merMod, which directs the user to ?vcov.merMod). This makes me confused.

Question: Why is this feature not clearly mentioned in the documentation? Have I understood it wrong, perhaps?

Ps. there seems to be a question about this on the R-mailing lists, but the answers make me even more confused.

library(lme4)
data(sleepstudy)

reml <- lmer(Reaction ~ Days + (Days | Subject), sleepstudy)
noreml <- lmer(Reaction ~ Days + (Days | Subject), sleepstudy, REML = F)

reml0 <- lmer(Reaction ~ (Days | Subject), sleepstudy)
noreml0 <- lmer(Reaction ~ (Days | Subject), sleepstudy, REML = F)

## Returns similar likelihood ratio test statistics:
(a <- anova(reml, reml0))
(b <- anova(noreml, noreml0))

## Not identical though
identical(a, b)
[1] FALSE

EDIT: sessionInfo: R version 3.0.2 (2013-09-25), lme4_1.0-5

Was it helpful?

Solution

At least as of recent versions of lme4, this is documented (albeit way down in the details) in ?anova.merMod (emphasis added):

‘anova’: returns the sequential decomposition of the contributions of fixed-effects terms or, for multiple arguments, model comparison statistics. For objects of class ‘lmerMod’ the default behavior is to refit the models with ML if fitted with ‘REML = TRUE’, this can be controlled via the ‘refit’ argument. See also ‘anova’.

OTHER TIPS

With thanks to Roland for doing the legwork, I'm posting my comment as the answer.

I'm not convinced the answers aren't the same: identical will return FALSE if any floating-point numbers aren't exactly the same or if any name of any variable differs. Can you take a look at the actual values of the returned elements of interest and see if they differ by more than machine precision? –

Roland ran the test and found that the only difference is the name attributes.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top