I am trying to setup my data for the mlogit-package in R, but somehow seem to run into trouble.
My data-frame is called choice2, and it looks like this:
id choice_id mode.ids choice weightloss adveffect inj tab infreq_1 infreq_3 cost
1 x1 A 0 3.5 0 1 0 1 0 550
1 x1 B 0 10.0 1 0 1 0 1 90
1 x1 C 1 0.0 0 0 0 0 0 0
1 x10 A 0 6.0 0 1 0 0 1 50
1 x10 B 0 3.5 1 0 1 1 0 165
1 x10 C 1 0.0 0 0 0 0 0 0
1 x11 A 0 2.0 1 1 0 0 1 165
1 x11 B 1 3.5 0 0 1 1 0 90
1 x11 C 0 0.0 0 0 0 0 0 0
1 x12 A 0 10.0 1 1 0 0 1 550
I setup my data for the mlogit-package in R by running the following command:
require(mlogit)
CLOGIT <- mlogit.data(choice2,
choice = "choice",
shape = c("long"),
id.var = "id",
alt.var = "mode.ids",
varying = 5:11,
chid.var = "choice_id",
)
However, this results in the following error-message:
Error in `row.names<-.data.frame`(`*tmp*`, value = c("x1.A", "x1.B", "x1.C", :
duplicate 'row.names' are not allowed
In addition: Warning message:
non-unique values when setting 'row.names': ‘x1.A’, ‘x1.B’, ‘x1.C’, ‘x10.A’, ‘x10.B’, ‘x10.C’, ‘x11.A’, ‘x11.B’, ‘x11.C’, ‘x12.A’, ‘x12.B’, ‘x12.C’, ‘x13.A’, ‘x13.B’, ‘x13.C’, ‘x2.A’, ‘x2.B’, ‘x2.C’, ‘x3.A’, ‘x3.B’, ‘x3.C’, ‘x4.A’, ‘x4.B’, ‘x4.C’, ‘x5.A’, ‘x5.B’, ‘x5.C’, ‘x6.A’, ‘x6.B’, ‘x6.C’, ‘x7.A’, ‘x7.B’, ‘x7.C’, ‘x8.A’, ‘x8.B’, ‘x8.C’, ‘x9.A’, ‘x9.B’, ‘x9.C’