Imagine someone sampled some chimpanzees, each chimpanzee was given two puzzle boxes to open to obtain a food reward (boxes A and B), for each case the person recorded success or failure to get the food reward. I only have the totals for each outcome – a total of (a) chimps opened both boxes, (b) opened B but not A, (c) opened A but not B, and (d) chimps opened neither. I want to test if the two box types are difficult to open or not. I used the following code:
a <- 16 # chimps who opened both boxes
b <- 16 # chimps who opened B but not A
c <- 29 # chimps who opened A but not B
d <- 17 # chimps who opened neither box
n <- a+b+c+d
chimp_ID <- c(rep(1:n, each=2))
environment <- c(rep(0:1, times=n))
a_chimps <- c(rep(0:0, times=a))
b_chimps <- c(rep(1:0, times=b))
c_chimps <- c(rep(0:1, times=c))
d_chimps <- c(rep(1:1, times=d))
event <- c(a_chimps,b_chimps,c_chimps,d_chimps)
library(lme4)
summary(glmer(event ~ environment + (1 | chimp_ID), family=binomial, nAGQ=17))
This seems to work fine and give rational answers except if I have two zeros in the data set, imagine that no chimps managed to open box B, so that a = b = 0, now the model always fails to converge. Can anyone suggest a solution to this?
0:0and1:1don't work the way you think they do (you needc(0,0)orrep(0,2)and similarly for the other case). Can you clarify that your example above is otherwise correct (i.e. you've edited since the comments anda=b=0is now the correct case to check? – Ben Bolker Mar 08 '21 at 21:37