Skip to content

nAGQ > 1 in lme4::glmer gives unexpected likelihood

3 messages · Ben Goldstein, Ben Bolker, Dimitris Rizopoulos

#
Hi all,

I'm using lme4::glmer to estimate Poisson mixed models in a very simple
context (single random effect). I'm interested in the model likelihood/AIC
across many simulated datasets.

To investigate whether the Laplace approximation was appropriate for my
data context, I explored using the argument nAGQ to improve the accuracy of
the likelihood estimation. When I changed nAGQ to a value > 1, I saw an
unexpectedly huge change in the likelihood; log-likelihoods tended to be
off by ~200. Other statistics packages (e.g. GLMMadaptive) yield estimates
that agree with lme4's Laplace approximation, as did a manual likelihood
estimate, and not with the nAGQ > 2 estimate.

The following code reproduces the problem I'm encountering.

*# r-sig-mixed-models GLMM question*
library(lme4)
set.seed(51)

*# Simulate some random effect-driven Poisson data*
random_effects <- rnorm(10, 0, 2)
group <- rep(1:10, 10)
simulated_data <- data.frame(y = rpois(n = 100, lambda = exp(3 +
random_effects[group])),
                             group = group)

*# Fit models with Laplace (nAGQ = 1) and nAGQ = 11*
fit_Laplace <- glmer(y ~ (1|group), data = simulated_data, family =
poisson())
fit_AGQ <- glmer(y ~ (1|group), data = simulated_data, family = poisson(),
nAGQ = 11)

logLik(fit_Laplace)
logLik(fit_AGQ)
logLik(fit_Laplace) - logLik(fit_AGQ) *# Huge difference!*

When I execute the above code, I see a difference in likelihood of
-218.8894. I've tested across many simulations and on 2 different machines
(Mac and Linux). My version of lme4 is up to date.

Has anyone run into this issue before? Am I using the glmer function wrong,
or is it possible there's something going on under the hood?

Thanks,
Ben
#
?It's entirely possible there's something going on under the hood.? 
IIRC there's a document somewhere that talks about how deviances and 
log-likelihoods are defined, and this may(?) still differ between nAGQ=1 
and nAGQ>1 ?
On 4/22/20 6:58 PM, Ben Goldstein wrote:
#
On a related topic, it is not clear to me whether glmer() updates the location of the quadrature points at each iteration when nAGQ > 1.



-----Original Message-----
From: R-sig-mixed-models <r-sig-mixed-models-bounces at r-project.org> On Behalf Of Ben Bolker
Sent: Thursday, April 23, 2020 1:30 AM
To: r-sig-mixed-models at r-project.org
Subject: Re: [R-sig-ME] nAGQ > 1 in lme4::glmer gives unexpected likelihood

 ?It's entirely possible there's something going on under the hood. IIRC there's a document somewhere that talks about how deviances and log-likelihoods are defined, and this may(?) still differ between nAGQ=1 and nAGQ>1 ?
On 4/22/20 6:58 PM, Ben Goldstein wrote:
_______________________________________________
R-sig-mixed-models at r-project.org mailing list
https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fstat.ethz.ch%2Fmailman%2Flistinfo%2Fr-sig-mixed-models&amp;data=02%7C01%7Cd.rizopoulos%40erasmusmc.nl%7C1bd598f4412543fa011308d7e715222e%7C526638ba6af34b0fa532a1a511f4ac80%7C0%7C0%7C637231950269193147&amp;sdata=vTYIo6nWnpQid01oBUizJ2hVU7JwRXgh3aRJunYO86c%3D&amp;reserved=0