# Mixed effects model error message: Model is nearly unidentifiable: large eigenvalue ratio

I am fitting a mixed effects model with a binary outcome. I have one fixed effect (Offset, a 3 level factor) and one random effect (chamber, with multiple data points coming from each chamber). I have included random intercepts that vary across chambers to account for the non-independence of data points that come from the same chamber. There are 27 chambers with 3-20 data points coming from each chamber. My code is as follows:

ball1=glmer(Buried~Offset+(1|Chamber), family=binomial,
data=ballData)


I then added random slopes to my model (that is allowed the slopes to vary across chambers) to see if I could imrpove the fit of the model. My code for this second model was

ball2=glmer(Buried~Offset+(Offset|Chamber), family=binomial,
data=ballData)


ball2 did run and produce parameter estimates, however it gave me the following error message:

In checkConv(attr(opt, "derivs"), opt\$par, ctrl = control$checkConv, : Model is nearly unidentifiable: large eigenvalue ratio - Rescale variables?

Nonetheless a comparison of the deviances between the two models showed that adding the random slopes did not improve the fit of the model. I have two questions (I have spent hours browsing the internet/other CV questions and am still unsure, so any help is much appreciated)

1) What does the error message mean and what can I do to fix the problem? I don't think I can rescale my variables because they are all factors.

2) I am including the random factor simply to control for any variation in the outcome variable across chambers so that I can test for the main effect of Offset. Is it correct to include both random slopes and intercepts to control for variation due to Chamber (i.e. (Offset|Chamber)), or is including only random intercepts sufficient to control for variation across Chambers (i.e. (1|Chamber))?

Here are the outputs for the models with and without the random slope. The first model (that includes random intercepts only, runs smoothly. When I add the random slopes (the second model), the warning appears.

    Generalized linear mixed model fit by maximum likelihood (Laplace
Approximation) [glmerMod]
Family: binomial  ( logit )
Formula: Buried ~ Offset + (1 | Chamber)
Data: ballData

AIC      BIC   logLik deviance df.resid
340.8    355.2   -166.4    332.8      267

Scaled residuals:
Min      1Q  Median      3Q     Max
-1.5886 -0.6587 -0.5681  0.7003  1.9255

Random effects:
Groups  Name        Variance Std.Dev.
Chamber (Intercept) 0.1574   0.3967
Number of obs: 271, groups:  Chamber, 27

Fixed effects:
Estimate Std. Error z value Pr(>|z|)
(Intercept)   0.7705     0.3010   2.559  0.01049 *
Offset2      -1.2389     0.4021  -3.081  0.00206 **
Offset3      -1.8705     0.4059  -4.608 4.07e-06 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Correlation of Fixed Effects:
(Intr) Offst2
Offset2 -0.723
Offset3 -0.765  0.545
>


Now for the model with the random slopes added:

    Generalized linear mixed model fit by maximum likelihood (Laplace
Approximation) [glmerMod]
Family: binomial  ( logit )
Formula: Buried ~ Offset + (Offset | Chamber)
Data: ballData

AIC      BIC   logLik deviance df.resid
347.5    379.9   -164.8    329.5      262

Scaled residuals:
Min      1Q  Median      3Q     Max
-1.7529 -0.5876 -0.5876  0.7008  1.9055

Random effects:
Groups  Name        Variance Std.Dev. Corr
Chamber (Intercept) 0.3795   0.6160
Offset2     0.8254   0.9085   -0.50
Offset3     0.3795   0.6160   -1.00  0.50
Number of obs: 271, groups:  Chamber, 27

Fixed effects:
Estimate Std. Error z value Pr(>|z|)
(Intercept)   0.8497     0.3771   2.253   0.0242 *
Offset2      -1.2570     0.5349  -2.350   0.0188 *
Offset3      -1.9132     0.4343  -4.406 1.05e-05 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Correlation of Fixed Effects:
(Intr) Offst2
Offset2 -0.705
Offset3 -0.868  0.612
convergence code: 0
Model is nearly unidentifiable: large eigenvalue ratio
- Rescale variables?


I have tried the following optimizers: however, they result in various new warnings:

ball2=glmer(Buried~Offset+(Offset|Chamber), family=binomial,
data=ballData,
control=glmerControl(optimizer="bobyqa"))
##
ball2=glmer(Buried~Offset+(Offset|Chamber), family=binomial,
data=ballData,
##
ball2=glmer(Buried~Offset+(Offset|Chamber), family=binomial,
data=ballData,
control=glmerControl(optimizer="optimx",
optCtrl=list(method="nlminb")))
##
ball2=glmer(Buried~Offset+(Offset|Chamber), family=binomial,
data=ballData,
control=glmerControl(optimizer="optimx",
optCtrl=list(method="L-BFGS-B")))


1) What does the error message mean and what can I do to fix the problem? I dont think I can rescale my variables because they are all factors.

It means that the curvature of the likelihood surface is very flat in some direction. You might have complete separation (do you have estimated parameter values larger than 5 or so??) Alternatively it might be a false positive. See ?convergence for ways of testing (e.g. if you fit with more than one optimizer and get the same answer, you're probably OK). It would be interesting to see a reproducible example.

2) I am including the random factor simply to control for any variation in the outcome variable across chambers so that I can test for the main effect of Offset. Is it correct to include both random slopes and intercepts to control for variation due to Chamber (i.e. (Offset|Chamber)), or is including only random intercepts sufficient to control for variation across Chambers (i.e. (1|Chamber)).

This is a bit of a can of worms: see e.g. my answer here. Generally the advice is "include in the model all random effects that can be estimated in the experimental design, if the data allow it/it doesn't make the model too complicated".

The updated information on your fit shows that you have a singular fit (as shown by the -1.00 correlation between (Intercept) and Offset3). That definitely makes a reasonable justification for simplifying the model to (1|Subject) ...

Random effects:
Groups  Name        Variance Std.Dev. Corr
Chamber (Intercept) 0.3795   0.6160
Offset2     0.8254   0.9085   -0.50
Offset3     0.3795   0.6160   -1.00  0.50

• Thank you for your thoughts Ben. I have pasted in the outputs of the two models. I don’t have parameter values over 5. I am very new to R and my statistical understanding is (embarrassingly) rather rudimentary; I did get a bit lost in the information provided in the ?convergence page. I did try some optimizers (code above), however Im not sure if I have even used the correct script. All of the optimisers that I tried provided various warning messages. Could you clarify what the optimisers do? And have I even used them correctly? Aug 29 '16 at 6:31
• Furthermore, given you advice regarding my 2nd question, I am wondering if I can get away with only including a random intercept (that varies by chamber), given that the addition of random slopes (that also vary by chamber) for two other predictors in the model does not improve the fit (I also do not get any warning message when I fit a random slope to these other predictors, it is only the Offset predictor that is causing problems). Perhaps by fitting random slopes I am unnecessarily complicating the model? Aug 29 '16 at 6:33