GLM with random factor in R

Question:

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.

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

I tried this:

modelo1<-glm(cbind(visitas,acertos)~cor_vantajosa*fase,random=~1|id,binomial(link="logit"),data=dados)

Every help is welcome!

Answer:

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