I've got a problem with the mlogit funtion in R. My dataset looks like this:
personID caseID altID choice a1 a2 a3 a4
1 1 1 1 3 0 3 1
1 1 2 0 1 3 0 1
1 1 3 0 4 4 4 4
1 2 1 0 2 2 1 3
1 2 2 1 2 3 1 3
etc....
I've tried running the following code, performing the model.
setV2 <- mlogit.data(data = setV2, choice = "choice", shape = "long", alt.var = "altID", chid.var = "personID")
m <- mlogit(choice ~ a1 + a2 + a3 + a4 | -1, rpar = c(a1 = "n", a2 = "n", a3 = "n", a4 = "n"), correlation = FALSE, halton = NA, TM)
However, I receive the following error (after the first line of code):
Error in dfidx::dfidx(data = data, dfa$idx, drop.index = dfa$drop.index, :
the two indexes don't define unique observations
a similar problem: Error with using mlogit R function: "The two indexes don't define unique observations"
Does any of you have an idea what's going wrong? Thanks in advance.