1

I am using the mlogit package in R and trying to run mlogit on the Train dataset that is available in the package. Here is my code:

mlogit.data(Train,shape='wide',choice = "choice", varying = 4:11, sep = "",alt.levels = c(1,2), id = "id")

I get the following error:

Error in [<-.data.frame(*tmp*, , v.names, value = c(2400, 2400, 2400, : column name "" cannot match any column In addition: Warning message: In dfidx::dfidx(data = data, dfa$idx, drop.index = dfa$drop.index, : the levels shouldn't be provided with a data set in wide format

I am not sure where is the mistake here.

riskiem
  • 187
  • 2
  • 7

1 Answers1

0

Try changing the sep param:

mlogit.data(Train, shape = 'wide', choice="choice",
                 varying=4:11, sep="_", id = "id")

I believe the dataset has changed since the example was created. The separator should be the underscore

Pierre L
  • 28,203
  • 6
  • 47
  • 69