The following is a minimum working example that generates the error. The following code worked in previous versions of mlogit but no longer works in version 1.1-0 (released May 26, 2020).
library(mlogit)
data("ModeCanada", package = "mlogit")
bususers <- with(ModeCanada, case[choice == 1 & alt == "bus"])
ModeCanada <- subset(ModeCanada, ! case %in% bususers)
ModeCanada <- subset(ModeCanada, noalt == 4)
ModeCanada <- subset(ModeCanada, alt != "bus")
ModeCanada$alt <- ModeCanada$alt[drop = TRUE]
KoppWen00 <- mlogit.data(ModeCanada, shape='long',
chid.var = 'case',alt.var = 'alt', choice = 'choice',
drop.index = TRUE, varying = 5:8)
Upon executing the last line of code above the following error is generated: Error in dfidx::dfidx(data = data, dfa$idx, drop.index = dfa#drop.index for data in wide format, providing id2 is irrelevant.
This error message is confusing in two ways. First, the code seems to be misinterpreting my data; the data is in long format (this is example "long" data that comes with the mlogit
package and works into several of their examples) and I pass the function the argument "long", but the error says the data is being interpreted as "wide" and that is causing a problem. The second part of the error message tells me that id2
is irrelevant, but I don't know what id2
is; a search of the mlogit
vignettes and package description for id2
yielded no results.