GLM with random factor in R


I need to do a glm in R, but there is a dependency between the data. I was asked to enter this dependency as a random factor in the analysis. But I'm not getting a command for that.

– GLM, binomial
– 2 response variables and 2 explanatory variables + random factor.

I tried this:


Every help is welcome!


You can use the glmer function from the lme4 package.

In your case it should look like this:

modelo <- glmer(cbind(visitas, acertos) ~ cor_vantajosa*fase + (1 | id), data = dados, family = binomial)
Scroll to Top