My outcome variable is binomial, and I have 11 independent variables and a time variable. The time variable has different slopes, so I fixed it to time-before and time-after. I used the lme4 package (the glmer function). I have a random intercept and two random slopes. I created my model like this:

m3.glmm <- glmer(y ~ timebefore + timeafter + x1 + x2 +...+ x11 +     
             data = data, family = binomial (link="logit"), nAGQ=3)

When I used this model, I had this error:

Error in updateGlmerDevfun(devfun, glmod$reTrms, nAGQ = nAGQ) : 
  nAGQ > 1 is only available for models with a single, scalar random-effects term

Anyone have a simple explanation of how to fit (or code) this model?


The problem is the number of abscissas, or nodes, you've selected for the Adaptive Gaussian Quadrature (AGQ) approximation of the log-likelihood, specified by nAGQ. The default value is 1 (equivalent to the Laplacian approximation).

The glmer function's Details section (page 29 in the lme4 help page) states:

The most reliable approximation for GLMMs is adaptive Gauss-Hermite quadrature, at present implemented only for models with a single scalar random effect.

Limiting the AGQ approximation to single scalar random effects is not a limitation of AGQ, but appears to be a decision made by the lme4 package writers, as noted here by Douglas Bates back in 2011 (relevant piece quoted below):

It may seem that this issue could be put to rest by incorporating an adaptive Gauss-Hermite method in glmer ... there has been such a method in versions of glmer but only for very specific models. We will add it but right now we are concentrating on other issues in the development.

So, to get your code to execute, I believe setting nAGQ to 1 would work.

| cite | improve this answer | |
  • 1
    $\begingroup$ But doing so , that is setting nAGQ=1 when I have random slope , will give biased estimates specifically for standard error of higher level ? $\endgroup$ – ABC Jul 22 '15 at 13:39
  • 1
    $\begingroup$ And if so will I quit R ( seems glmer is probably best for GLMM in R ) and use another software such as STATA , SAS ? $\endgroup$ – ABC Jul 22 '15 at 13:43
  • 3
    $\begingroup$ @ABC right; it's definitely a limitation of glmer. From Douglas Bates in the link I provided in my answer: "In some ways I think that reliable optimization of the approximate log-likelihood is more important and that is an area where R is not strong. Far too much optimization code is covered by licenses that are not compatible with R's license and the pickings for Open Source optimization code are somewhat slim. I wish I had access to some of the optimizers that SAS uses but we don't so we make use of what we do have." Note: I have no concept of how relevant this comment is in 2015. $\endgroup$ – user5594 Jul 22 '15 at 13:52
  • 5
    $\begingroup$ I don't know whether SAS does AGQ (i.e. as distinct from Laplace, with >1 quadrature point) for vector-valued random effects. GLLAMM in Stata definitely does (see andrewgelman.com/2010/09/10/r_vs_stata_or_d). @MikeWierzbicki, your quotation is a little off target; the absence of vector-valued AGQ in lme4 is not due to lack of optimization code (we now have Steve Johnson's NLOptr to build on), but rather the absence of the appropriate code in github.com/lme4/lme4/blob/… (search for glmerAGQ) ... $\endgroup$ – Ben Bolker Jul 22 '15 at 14:23
  • 3
    $\begingroup$ @BenBolker +1 -- thanks for the clarification! That's definitely good to know. $\endgroup$ – user5594 Jul 22 '15 at 14:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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