我正在尝试使用R中的mlogit包来解决带有变量选择集的离散选择模型。我相信这项工作应该:
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)
其中data.csv是:
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
即。我正在考虑一个与铁路网络中的路线选择相关的合成示例,该路线选择基于路线中的车站数量和交汇处数量。
当我检查预测时,我发现选择集之外的路径被赋予非零概率。
我无法找到一个使用不同选择集的mlogit的好例子,所以很可能我错误地指定了模型或数据。有任何想法吗?感谢。