5

I'm trying to use the mlogit package in R to solve a discrete choice model with a variable choice set. I believe this work should with:

library(mlogit)
mydata = read.table("data.csv",sep = ",", header=TRUE)
routes <- mlogit.data(mydata, shape = "long", choice="choice", alt.var = "alternative", chid.var = "individual")
routeChoice <- mlogit(choice ~ num_stations + num_interchanges | 0 | 0, routes)
predictions <- predict(routeChoice,newdata=routes)

where data.csv is:

individual,alternative,choice,num_stations,num_interchanges,count,prop
1,AB,1,1.0,0.0,2,0.04742587317756678
1,ACB,0,5.0,1.0,2,0.04742587317756678
2,AB,0,1.0,0.0,48,0.9525741268224331
2,ACB,1,5.0,1.0,48,0.9525741268224331
3,AC,1,2.0,0.0,6,0.11920292202211755
3,ABC,0,4.0,1.0,6,0.11920292202211755
4,AC,0,2.0,0.0,44,0.8807970779778824
4,ABC,1,4.0,1.0,44,0.8807970779778824
5,BC,1,3.0,0.0,13,0.2689414213699951
5,BAC,0,3.0,1.0,13,0.2689414213699951
6,BC,0,3.0,0.0,37,0.7310585786300049
6,BAC,1,3.0,1.0,37,0.7310585786300049

i.e. I am considering a synthetic example related to route choice in a railway network based on the number of stations in the route and the number of interchanges.

When I inspect the predictions I find that routes outside the choice set are being assigned non-zero probability.

I haven't been able to find a good example of using mlogit with a varying choice set, so it is likely I am specifying the model or data incorrectly. Any ideas? Thanks.

Chirayu Chamoli
  • 2,076
  • 1
  • 17
  • 32
Charles
  • 51
  • 3
  • 1
    did you ever find an answer to this question? I am also looking for a way to specify varying choice-sets for `mlogit` models. – Inhabitant Jul 11 '17 at 12:15

0 Answers0