0

In the past I've typically analysed accuracy data, so I have used the lme4 package to run binomial logistic models. In lme4, I can specify random effects (Participant and Item) like this:

glmer(Outcome ~ Condition + (1|Participant) + (1|Item), family=binomial, data = Data)

I've been using the mlogit package for the first time to analyse multinomial data from a behavioural experiment. Participants answered multiple-choice questions with three possible options. The three options were the same for every single question.

Based on guidance online, I have formatted the data using difidx():

Model_data <- dfidx(data=Data, choice="Selected", alt.levels=c("Choice1", "Choice2", "Choice3"), shape="wide", idx = list(c("chid", "Participant", "Item")))

I've specified Participant and Item in the idx list as these columns have panel information (participant IDs and item IDs) that I'd like to include in the model as random effects.

I've then successfully run the multinomial model without using random effects using this code:

Model <- mlogit(Selected ~ 1 | Condition, data=Model_data, reflevel="Choice1")

I can't figure out how to incorporate random effects in the model, despite reading the vignette and other similar stack overflow questions. As Participants answer multiple questions, and Items are repeated, I know I should specify rpar() and put that it is panel data. I have tried the following:

Model_random <- mlogit(Selected ~ 1 | Condition, rpar=c(Participant = "n", Item = "n"), data=Model_new, reflevel="Choice1", panel=TRUE)

However, I get the error: Error in mlogit.start(formula = formula, data = data, mf = mf, start = start, : unknown random parameter

I've seen other examples where the Condition of interest is entered in rpar() so I don't know if I'm incorrectly interpreting the syntax. Please can I have advice on how to include random effects of Participant and Item for my specific example? Thank you!

  • 2
    Even though you've included a good amount of code, a [workable sample of data](https://stackoverflow.com/q/5963269/5325862) would be helpful so folks can run it. You also might find something on [stats.se]; I don't think this should be moved there, but there are probably posts that would help – camille Sep 20 '21 at 14:43

0 Answers0