The help states:
The ‘data’ argument may be an ordinary ‘data.frame’. In this case, some supplementary arguments should be provided and are passed to ‘mlogit.data’.
You have not given any supplementary arguments. Note that I consider this poor documentation because it does not state which supplementary arguments should be provided.
From the examples, it seems that "shape" and "choice" should at least be set:
# a data.frame in wide format with two missing prices
Fishing2 <- Fishing
Fishing2[1, "price.pier"] <- Fishing2[3, "price.beach"] <- NA
mlogit(mode~price+catch|income, Fishing2, shape="wide", choice="mode", varying = 2:9)
# a data.frame in long format with three missing lines
data("TravelMode", package = "AER")
Tr2 <- TravelMode[-c(2, 7, 9),]
mlogit(choice~wait+gcost|income+size, Tr2, shape = "long",
chid.var = "individual", alt.var="mode", choice = "choice")
By the way, welcome to stackoverflow! Here are some tips on writing a better question and thus increasing the chance of a good answer.
- you should state the package from which your command comes. I'm assuming it is from the mlogit package, but the mlogit command is in every package.
- you should give a minimal example. You give the output of the
head
command, but it's not clear if the error can be reproduced with that.library(mlogit)
should also be given in your minimal example. - you should read the help for the command. Help files can be intimidating and very technical, but you don't have to understand everything in them. In your example, I'm guessing that
some supplementary arguments should be provided
would have jumped out at you. In case you're not sure how to access help for the commandmlogit
, you can use?mlogit
orhelp(mlogit)
.