0

I am trying to run a mixed effect multinomial model. Below is some of my data.

id          outcome         x
1008         two        -0.36759425
1008         two        -0.36759425
1008         two        -0.36759425
1008         two        -0.36759425
1008         one        -0.36759425
1008         two        -0.36759425
1008         two        -0.36759425
1008         one        -0.36759425
1012         two        -0.08572346
1012         one        -0.08572346
1012         three      -0.08572346
1012         two        -0.08572346
1012         three      -0.08572346

I have 2 questions. First, if my data are already in the long format, do I need to specify it to be in the long format.

Second, when I run the code below, I am getting the error message below:

> a <- mlogit(outcome ~ 1 | short_sleep_tm_05r, data = df, reflevel = "one")

Error in dfidx::dfidx(data = data, dfa$idx, drop.index = dfa$drop.index,  : 
  the two indexes don't define unique observations

I don't understand what this means. Can someone help?

D. Fowler
  • 601
  • 3
  • 7
  • if you look at the example data frame, there's 3 entries of id = 1008, outcome =2, x=-0.36759425 , so somehow your observations are duplicated? – StupidWolf Sep 06 '20 at 16:51
  • You need to address that, and make sure your observations are unique – StupidWolf Sep 06 '20 at 16:52
  • Hi @StupidWolf. The data are repeated measures though. I thought I could run a multinomial mixed effect model with mlogit. Is that not the case? – D. Fowler Sep 06 '20 at 19:26

0 Answers0