0

I am working with a conjoint dataset and estimating multinomial logit models. To work with the mlogit package I had to convert the data, which I did like this:

dat <- mlogit.data(dat, choice="Selection_dummy", shape="long", alt.var="Alt_id", id = "Resp_id")

After converting the data, estimating the MNL model works fine. However, I cannot view the dataset anymore as it retrieves the following error:

View(dat)

Error in [.data.frame (x, start:min(NROW(x), start + len)) : undefined columns selected Error in [.data.frame (x, start:min(NROW(x), start + len)) : undefined columns selected

Then, when I want to estimate a latent class model this provides the error that there is no individual index. I think this might have to do with converting the dataset?

lc2<- gmnl(Selection_dummy ~ aa + ab + ba + bb + bc + ca + cb + cc + da + db + ea + eb + None | 0 | 0 | 0 | 1, data = dat, model = 'lc', Q = 2, panel = TRUE, method = "NR")

Error in gmnl(Selection_dummy ~ aa + ab + : No individual index

I can't seem to find the issue, so does someone know what's going wrong here and how it can be solved?

Thanks a lot!

TarJae
  • 72,363
  • 6
  • 19
  • 66
Niels
  • 1
  • 2
    Hi, welcome to StackOverflow. Can you provide a small dataset that reproduces these errors? That would make it a lot easier for people to help finding what is wrong. Some instructions can be found here: https://stackoverflow.com/a/5963610/5805670 – slamballais May 15 '21 at 10:18

1 Answers1

0

Try head(dat, 5) instead. For some reason the converted dataframe will not show up with view.

It is possible that mlogit did not convert your data correctly. If you do not see : in the chid column, there is a problem with the conversion.

Setting the variables to the correct one solved my problem.