# Multilevel nested glmer model (logistic regression) with 4 groups

I have 3 level nested data that is causing convergence problems (glmer function in lme4, R for multilevel logistic regression).

### The Data

Country(4 groups) -> School(100 groups) -> respondent
A respondent is nested within school, and the school (id number) is nested within country. Each school id.number is only within one country. So school-1 is only in Country-A.
Data is c.a. 8000 rows. Final model has 10 variables (three 2-level factors, 6 covariates + Country)

COUNTRY    SCHOOL  GENDER  RESPONSE.VAR ...
Cntry-A    1       m       0
Cntry-A    1       f       0
Cntry-A    2       m       1
Cntry-B    10      f       0
Cntry-B    10      f       1
Cntry-B    11      m       1
Cntry-C    100     f       0
Cntry-C    100     f       1
...        ...     ...     ...


### The problem

• Country has too few levels, four is not enough to have as a random intercept. But I wonder if it is okay to have so few groups for level-3 if level-2 has so many groups, because School is nested within Country?
• Because I am confident that four levels is not enough, and because I am actually interested in the country variable, I have included it as a fixed effect rather than random.
• I hypothesize that the effect of covariate1 on response.var is different within each country.

### The model

library(lme4)
with(Df,
glmer(response ~
covar1*country +
gender +
... +
(1|school),
family="binomial"))


### The question

• Why am I getting convergence warning for the final model? Can I trust the results?
• I have read a lot about this. Using more iterations and other optimizers sometimes fixes the problem. And using optimx fixes the problem as well. Running the model with many differnt optimizers (as suggested by lme4 auth) shows nearly identical results, so according to them I can ignore the convergence warnings.
• But I would like to use multiple imputation for the data. With imputed data I cant use optimx.
• I use grand mean centering for covariates.
• Am I defining the model correctly? Adding Country (interaction or just as main effect) creates convergence issues.
• Is it because the model has 100+ intercepts, one for each school. And a school is only within one country?

The default estimation procedure of glmer() is a Laplace approximation that is known not to be optimal for binary data. You could try using adaptive Gaussian quadrature by adjusting the nAGQ argument.