I am seeing this error is appearing with various other packages,for instance here, but the solutions do not seem to apply here.
I am using the gmnl package and want to do a mixed logit, but run on the following error
Error: $ operator is invalid for atomic vectors
I previously ran a multinomial logit model with gmnl on the same data with no error.
Here is what my data looks like, once put in the mlogit.data format: sample of discrete choice experiment data
Here is my code for the multinomial model (no issue) and the mixed logit, which returns the error:
#MULTINOMIAL LOGIT
mln <- gmnl(choice ~ inf_50 + inf_100 + heat_20 + heat_40 + heat_60 + red_car + dist_0 + dist_100 + dist_500 + SQ + payment | 0 ,
data = data,
haltons = 50)
summary(mln)
#MIXED LOGIT
mxl <- gmnl(choice ~ inf_50 + inf_100 + heat_20 + heat_40 + heat_60 + red_car + dist_0 + dist_100 + dist_500 + SQ + payment | 0 ,
data = data,
model = 'mixl',
ranp = c(inf_50 = "n",
inf_100 = "n",
heat_20 = "n",
heat_40 = "n",
heat_60 = "n",
red_car = "n",
dist_0 = "n",
dist_100 = "n",
dist_500 = "n",
SQ = "n",
payment = "n"),
panel = TRUE,
R = 30,
haltons = 50)
I can provide more information if necesary, as well as share the data.
I understand the atomic vector error, but in this case I am following the syntax given in the gmnl package. With the examples (the Electr one) from gmnl, this error does not appear.. Could it be that some of my data is of the wrong type ? All the parameters called in the model are integers. I am at a loss there.
Thanks a lot!