Convergence problem in generalized linear mixed models

generalized linear modellme4-nlmemixed modelrregression

My outcome variable is called PB, and it is a binary variable: 0 or 1.
I have used generalized linear mixed models (GLMM) because each subject ($n=238$) was measured twice (overall observations = 476)

Using GLMM with a logit function, I have built an empty model with random intercepts. This how I did it in R:

FirstModel <- glmer(data = DATA_LONG3, PB ~ 1 + (1|userId), 
                    family = "binomial")

Though when I ran it, I got these warnings:

Warning messages:
1: In checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv,  :
  Model failed to converge with max|grad| = 0.0852968 (tol = 0.002, component 1)
2: In checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv,  :
  Model is nearly unidentifiable: very large eigenvalue
 - Rescale variables?

Just to give points on context:

  • Overall there are 476 observations ($n=476$), 62 of them PB = 1, and 414 are PB = 0.
  • In the first measurement: ($n=238$), 215 are PB = 1, and 23 are PB = 0.
  • In the second measurement: ($n=238$), 199 are PB = 1, and 39 are PB = 0.

Can someone tell me how crucial this problem is for my results, and maybe give me a solution?

Best Answer

To obtain convergence (which as @ShawnHemelstrand 's answer points out is not your only issue) increase the default value of nAGQ = 1 to at least 8 to get a relatively stable result:

glmer(data = DATA_LONG3, PB ~ 1 + (1|userId), family = "binomial", nAGQ = 8)

You gave almost every thing necessary to duplicate your data for use with the model given. One just needs to find the number of userId's that are 00, 01, 10, and 11. Those counts are labeled c00, c01, c10, and c11. We find that 179 <= c00 <= 199 and the rest of the counts are then determined. It turns out that c00 = 189 and c00 = 190 result in the same error you had.

Using c00 = 189 we have

library(lme4)

# 176 <= c00 <= 199    176 to 180 gives some different error
#                      181 to 188 and 191-199 works as is
#                      189 and 190 produce same errors as you found
c00 <- 189
c01 <- 215 - c00
c10 <- 199 - c00
c11 <- c00 - 176

obs <- matrix(c(rep(c(0,0), c00), rep(c(0,1), c01), rep(c(1,0), c10),
  rep(c(1,1), c11)), byrow=TRUE, ncol=2)
DATA_LONG3 <- data.frame(userId=factor(c(1:238,1:238)), PB=c(obs[,1], obs[,2]))

glmer(data = DATA_LONG3, PB ~ 1 + (1|userId), family = "binomial", nAGQ = 8)

Generalized linear mixed model fit by maximum likelihood (Adaptive Gauss- 
  Hermite Quadrature, nAGQ = 8) [glmerMod]
Family: binomial  ( logit )
Formula: PB ~ 1 + (1 | userId)
Data: DATA_LONG3
      AIC       BIC    logLik  deviance  df.resid 
 352.8489  361.1798 -174.4245  348.8489       474 
Random effects:
Groups Name        Std.Dev.
 userId (Intercept) 2.059   
Number of obs: 476, groups:  userId, 238
Fixed Effects:
(Intercept)  
     -3.045  
Related Question