R&#mogogit是否处理多种独特的替代方案?

时间:2017-07-05 11:02:26

标签: r logistic-regression mlogit

客户面临着一系列独特替代品的选择。例如:

客户1在备选方案A1,A2,A3,A4之间进行选择; 客户1在输入B1,B2之间进行选择; 客户2在备选方案C1,C2,C3之间进行选择; 客户2在备选方案D1,D2,D3之间进行选择 等

任何R套餐都可以处理吗?

例如.csv

CHOICE,CUSTOMER,CHID,ALT,DIST,INCOME
1,1,1,1,100,70
0,1,1,2,372,70
0,1,1,3,417,70
0,1,1,4,180,70
1,1,2,1,68,70
0,1,2,2,354,70
0,2,3,1,68,100
0,2,3,2,354,100
1,2,3,3,399,100
1,2,4,1,180,100
0,2,4,2,100,100
0,2,4,3,80,100

mlogit 失败

> library(mlogit)
> ExData <- read.csv("C:/Users/John/Desktop/R/example.csv")
> MLData <- mlogit.data(ExData, shape="long", choice="CHOICE", chid.var="CHID", id.var="CUSTOMER", alt.var="ALT")
> res <- mlogit(CHOICE~DIST|INCOME, data=MLData, shape="long", alt.var="ALT")
Error in `row.names<-.data.frame`(`*tmp*`, value = paste(chid, alt, sep = ".")) : 
duplicate 'row.names' are not allowed
In addition: Warning message:
non-unique values when setting 'row.names': ‘2.1’, ‘2.2’, ‘3.3’

而example1.csv,其中备选方案的数量是常数

CHOICE,CUSTOMER,CHID,ALT,DIST,INCOME
1,1,1,1,100,70
0,1,1,2,372,70
0,1,1,3,417,70
0,1,2,1,180,70
1,1,2,2,68,70
0,1,2,3,354,70
0,2,3,1,68,100
0,2,3,2,354,100
1,2,3,3,399,100
1,2,4,1,180,100
0,2,4,2,100,100
0,2,4,3,80,100

一切都很好。

0 个答案:

没有答案