5

I have a dataset in which individuals, each belonging to a particular group, repeatedly chose between multiple discrete outcomes. Something akin to:

subID  group   choice
1      Red     A
1      Red     B
2      Blue    B
2      Blue    B
2      Blue    C
3      Red     A
3      Red     B

I'm interested in how group membership predicts choice, and want to account for non-independence of observations due to repeated choices being made by the same individuals. In turn, I planned to implement a mixed multinomial regression treating subID as a random effect.

It would appear that mlogit is a common route for mixed logits. However, I am a bit unclear as to how to set the desired random effect. I was wondering:

  1. Does that seem like the best approach for R-based analysis?

  2. In reviewing the discussions had here and here, I'm a bit thrown off by the mlogit scheme. Can I indeed account for subID via the rpar argument?

Any guidance would be thoroughly appreciated.

kjetil b halvorsen
  • 63,378
  • 26
  • 142
  • 467
jjcii
  • 65
  • 1
  • 6
  • the function mblogit in package mclogit seems to have helped me solve this same issue. CRAN link here: https://cran.r-project.org/web/packages/mclogit/index.html – pdawg92 May 14 '21 at 14:24

1 Answers1

3

If you use mlogit to analyse your data, then I would advise you to also use mlogit.data to put the data in the right shape. Regarding mlogit, you can specify random coeff with the rpar command (eg rpar=c(A='n') means that A is a random effect which is normally distributed) - if you only want to account for the panel nature of the data then specify panel=TRUE

Nicolas K
  • 859
  • 7
  • 14
  • Thank you, quite helpful. I've successfully shaped the data to long form. However, I'm now struggling with the mlogit arguments. I've tried the following: `mlogit(choice ~ subID | group, rpar=c(subID="n"), panel=TRUE, data = mydata)` However, this returns the following: `Error in mlogit.start(formula = formula, data = data, mf = mf, start = start, : unknown random parameter` Any suggestions on how to correctly enter these needed arguments? Additionally, is it correct to set subID, a factor, to a normal distribution? Many thanks. – jjcii Mar 02 '19 at 03:18
  • You can't specify "subID" as a predictor - It is simply a variable describing the structure of the data. I think the correct syntax would be something like: choice ~ 1 + group, rpar=c(group='n'). I think it is fine to specify a factor as random parameter - Mlogit should automatically create dummy variables for the different modalities and then apply the selected distribution to the dummies (so if you have 4 dummies and specify a normal distribution, mlogit will estimate 4 mean and 4 variance parameters - You can also estimate covariance parameters with the CORR option [From what I remember]) – Nicolas K Mar 02 '19 at 08:37
  • Unfortunately that results in the same error. I was under the impression that that syntax would implement a random effect for group (for which I'm actually interested in a fixed effect) rather than for the individual. Should group be entered as `| group` rather than `+ group` in this case? (see [link](https://bit.ly/2El9bVO)) Additionally, revisiting the vignettes, it seems covariates used with rpar must be alternative specific. To clarify: if within mlogit.data `ind.var = subID`, does that already account for the repeated observations across individuals? Is rpar even needed in this case? – jjcii Mar 02 '19 at 17:46
  • Rpar only admits alt-specific variables. If your are interested in FE for group and to account for panel nature of data - then forget about rpar and simply use the panel option - not sure how to specify FE in mlogit - eventually do it manually (create dummy variables) – Nicolas K Mar 02 '19 at 18:35
  • Thanks, much clearer now. It seems the panel argument requires the inclusion of the rpar argument (`Error: panel is only relevant for mixed logit models`), so I still need to figure out whether the effect of individual as choice index needs to be accounted for by some other means (vs. is automatically accounted for when setting that variable as the ind.var in mlogit.data). In any case, knowing I don't need to implement rpar is quite helpful! – jjcii Mar 02 '19 at 22:32