5

我正在尝试使用 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 和不同选择集的好例子,所以很可能我错误地指定了模型或数据。有任何想法吗?谢谢。

4

0 回答 0