# Coding schemes for analysing multinomial data using lme4 binary logistic regression

Data: I have data where each trial is a categorical response from a four-way un-ordered forced choice task (A,B,C,D) by participants. I am interested in the factors that influence the choice. The data set is unbalanced (incomplete crossover of participants and stimuli)

Methods: I am analysing it using mixed effect binary logistic modelling using the lme4 library, since there are no easy-to-use multinomial mixed effect models implemented in R at the moment. I have two ideas that involve using lme4.

Questions: I am particularly curious about idea 2 and whether it is kosher or not.

Idea 1: Analyse it using four separate binary logistic models, each with the response variable being one of the four categories vs rest (e.g. A vs non-A, B vs non-B etc.)

Idea 2: Analyse it using one single binary logistic model. I would recode each trial as four fake trials with the four target responses (A,B,C,D) respectively and the actual response is True or False; say the original trial has the response A; the fake trial with the target response A would get the value True, the other three would get the value False.

e.g. Say the raw data is: Trial 1: A, Trial 2: C, Trial 3: B ... I would code each trial as four fake trials, I would have a column "Target Response" which is always A,B,C and D (one each), and an additional column "Choice" with TRUE/FALSE. "Choice" would get the TRUE value if it's the actual one being picked", else FALSE. "Trial ID", "Choice", "Target Response" 1, TRUE , A 1, FALSE, B 1, FALSE, C 1, FALSE, D 2, FALSE , A 2, FALSE, B 2, TRUE, C 2, FALSE, D 3, FALSE , A 3, TRUE, B 3, FALSE, C 3, FALSE, D

• Is this method kosher at all? I am thinking this might not be kosher because it is not possible for each of the "Trial ID" to have more than one TRUE in reality but the coding scheme here allows for that impossibility

• To mediate this faking of trials, should I group each of these four fake trials with a code and include this code as a random effect? That is the inclusion of "Trial ID" as a random intercept might help (or does it?).

• Should I also include "target response (A,B,C,D)" as a random effect? Would this be able to model the inherent preference for each of the four choices?

• Besides the ability to model the choice of picking A,B,C and D in a single model, I like idea 2 because it seems to allow me to model why people didn't pick the other 3 alternatives for each trial (that is the picking of "A" is influenced by why they do not want to pick "B", "C" and "D"). If I do not recode the data at all, I don't seem to be able to model this.

## migrated from stackoverflow.comSep 5 '17 at 15:22

This question came from our site for professional and enthusiast programmers.

• I think you should look into doing this using MCMCglmm instead. Regardless, this would be better suited at Cross Validate, and I'm voting to migrate. – Axeman Sep 5 '17 at 14:46
• AFAIK, you can also fit this in brms (via family = categorical). A reproducible example would be useful, though. – alexforrence Sep 5 '17 at 17:57