Testing glmer model assumptions (optionally in R) I have collected binary data within subjects (multiple trials per subject) and have fit a generalized mixed effect regression to these data. My model has the following structure:
fit <- glmer(Y ~ X1 + X2 + (1 + X1 + X2 | A) + (1 + X1 + X2 | B),
data = data,
family = "binomial")
I would like to check for possible violations to the model assumptions, but I am unsure concerning (a) the actual assumptions that need to be tested for within a mixed effect logistic regression, and (b) how these can be tested in R. Checking for model assumptions appears to be much more complex than in the simple regression setting and I would really appreciate if someone could refer me to useful documents, books, or R-packages.
I assume I would need to check for a linear relationship between my independent variables and the log of the odds, for example, but I cannot find a comprehensive overview or a systematic approach to the diagnostics.
Thank you in advance!
 A: Considering your model, there is a bunch of assumptions that should (must) be tested.
First, because you use a binomial distribution, you should check if there is no over or under-dispersion in your model. This can be tested with the package DHARMA. It will also help you to check if your model adequatly fits your data be investigating simulated residuals. It will aslo flag potential outliers.
For your random effect, you have two separated blocks (A and B). For each one, your model assumes that the random coefficients and intercepts follow a multivariate normal distribution. It is difficult to assess if this assumption is valid, but a qqplot on the random coefficients and intercepts should give good insights. The package MVN could be used to dig deeper into this.
You must also check for multicolinearity between your predictors and ensure that no perfect seperation is provoqued by one of them. Perfect separation means that a variable is able to perfectly predict your response.
Finally, I recommend to compare your predicted categories (0 or 1 I guess in your case) with the real ones and ensure that your model makes credible predictions. This can be achieved with the ROCR and caret packages.
That is a lot of work and will require some code, but all the libraries mentionned above have a really good documentation.
