GLMM with binomial

df <- data.frame(Fibro=sample(x=c("Oui", "Non"), 1000, replace=TRUE),
                 year=floor(runif(1000, min=2004, max=2010))-2000,
                 ID=sample(x=1:100, 1000, replace=TRUE))
df2 <- cbind(df, FibroNum=as.numeric(df$Fibro=="Oui"), NonFibroNum=1-as.numeric(df$Fibro=="Oui"))
df2$year <- df2$year + df2$FibroNum
df2$Fibro <- as.factor(df2$Fibro)
df2$ID <- as.factor(df2$ID)
head(df2)

library(lme4)

These solutions are equivalent

g1 <- glmer(formula = Fibro ~ year + (1 | ID), data=df2, family=binomial(link="logit"))
g2 <- glmer(formula = FibroNum ~ year + (1 | ID), data=df2, family=binomial(link="logit"))
g3 <- glmer(formula = cbind(FibroNum, NonFibroNum) ~ year + (1 | ID),
            data=df2, family=binomial(link="logit"))

library(cAIC4)

cAIC(g1)
cAIC(g2)
cAIC(g3)

Commentaires

Posts les plus consultés de ce blog

Standard error from Hessian Matrix... what can be done when problem occurs

Multivariable analysis and correlation of iconography

Install treemix in ubuntu 20.04