# Mixed effect logistic regression in R: choosing random effects

I conducted an experiment which measured a binary response for each subject. The subjects were in 1 of 3 groups. There were two other fixed factors, each of which were continuums (cont1, cont2) ranging from 0 to 10. In other words, for each step in cont1, there was a corresponding 0-10 step continuum (cont2). Cont1 refers to formant frequency of a vowel and cont2 refers to vowels duration. Therefore, there was a total of 121 stimuli repeated 7 times. Each subject provided 847 responses.

I would like to know how the three groups differ in there responses for the two continua. Groups 1 and 2 are control groups (I know more or less how they behave), but I am interested in group 3 and if they perform more like group 1 or group 2.

I have used the following model in R using lme4:

full.mod <- glmer(response ~ cont1+cont2+group+(random effects), data=df, family=binomial)


I think that I need the interaction between the three fixed effects to answer my research question; however I am not sure.

full.mod.int <- glmer(response ~ cont1*cont2*group+(random effects), data=df, family=binomial)


Therefore, my first question is whether full.mod or full.mod.int is the best choice. My experience with ANOVA leads me to believe that I need the interactions, however, being that there are 11 levels for each continuum, the output of coefficients is going to be enormous, and this makes me think that something is not right.

With regard to random effects, I know that I should include random intercepts for each subject (1|subject). However, it is not clear to me whether or not I need a random effect for items too. In this case, both cont1 and cont2 are items. I have a column in my data farm called stimuli which gives information like: cont1_0_cont2_0, cont1_0_cont2_1, etc. Assuming this is what I should do, my model now looks like this:

full.mod.int <- glmer(response ~ cont1*cont2*group+(1|subjects)+(1|stimuli), data=df, family=binomial)


Would there be any benefit to adding random slopes? If so what would they be (cont1,cont2?)?

• To answer your research question, it is all about interactions between group and the two items. So the model without any interaction wont help. Maybe to not drown in parameters, you could try to represent the two items by a single parameter (linear effects on log-odds) each per group? – Michael M Jan 2 '14 at 17:35
• Thank you for your reply. Your suggestion is interesting. In order to do that I believe I would need to do the following: 1) fit a model (response~cont1+cont2) for each group separately. 2) calculate the log-odds for each step of the two continua and put them into a separate data frame. 3) combine the data frames of the 3 groups. 4) fit a linear model (log-odds~group+(1|subj)). Does that sound right? – babylinguist Jan 2 '14 at 18:19
• What question are you trying to answer with this analysis? – AdamO Jan 2 '14 at 18:25
• No. I meant using number and duration as numeric variables in the model, each with group interaction. (121 lines per subject, only a random subject intercept.) But it is difficult to say. A nice experiment though! – Michael M Jan 2 '14 at 18:31
• AdamO - I would like to know how the three groups differ in there responses for the two continua. More specifically I would like to know if the duration (cont2) of the vowel (cont1) affects responses as a function of group. – babylinguist Jan 2 '14 at 18:36