# Which is the best method to analyse binary data in mixed models?

I wonder if there are suggestions about which method do use to analyse this type of data. My idea is to use glmer, or is there a better option?

id <- rep(c(300,450,600), each=6)
> visit <- rep(1:6,3)
> trt <- rep(c(0,"A",0,"B",0,"C"),3)
> q1 <- c(2,1,2,1,2,2,2,1,2,1,2, 2,2,1,2,1,2, 2)
> df <- data.frame(id,visit,trt,q1)
> df
id visit trt q1
1  300     1   0  2
2  300     2   A  1
3  300     3   0  2
4  300     4   B  1
5  300     5   0  2
6  300     6   C  2
7  450     1   0  2
8  450     2   A  1
9  450     3   0  2
10 450     4   B  1
11 450     5   0  2
12 450     6   C  2
13 600     1   0  2
14 600     2   A  1
15 600     3   0  2
16 600     4   B  1
17 600     5   0  2
18 600     6   C  2
> reshapeDF <- function(DF, colnr) {
+   dfTRT <- DF[DF$$trt!=0,] + df0 <- DF[DF$$trt==0,]
+   DFNew <- dfTRT[,c(1:3, colnr)]
+   colnames(DFNew)[4] <- 'Q'
+   DFNew\$bl <- df0[,colnr]
+   return(DFNew)
+ }
> reshapeDF(df,4)
id visit trt Q bl
2  300     2   A 1  2
4  300     4   B 1  2
6  300     6   C 2  2
8  450     2   A 1  2
10 450     4   B 1  2
12 450     6   C 2  2
14 600     2   A 1  2
16 600     4   B 1  2
18 600     6   C 2  2

I'm thinking a model like
df<- glmer(formula= Q ~  trt + bl +(1|id) ,family=binomial , data=df)

• Where is the issue? Why do you think glmer is not enough? – user2974951 Aug 22 '19 at 13:15