每次尝试在此数据上使用“mlogit”运行混合 logit 模型时,我都会收到此错误,并且我无法弄清楚我缺少什么。这是来自关于车辆的联合调查的离散选择数据。使用效果编码对数据进行编码。以下是我为 mlogit 准备数据的方式:
DATA <- mlogit.data(data, id.var="id", shape="long", choice="choice", alt.var="alt")
> head(DATA)
id Task alt Answer choice Price2 Price3 Price4 Price5 American Japanese
1.1 1 1 1 3 FALSE 0 0 1 0 0 0
1.2 1 1 2 3 FALSE 0 0 0 1 0 0
1.3 1 1 3 3 TRUE -1 -1 -1 -1 -1 -1
2.1 1 2 1 1 TRUE -1 -1 -1 -1 0 0
2.2 1 2 2 1 FALSE 0 1 0 0 1 0
2.3 1 2 3 1 FALSE 0 0 1 0 0 1
Chinese SKorean HEV PHEV10 PHEV20 PHEV40 EV75 EV100 EV150 F20 F30 FNA s6
1.1 0 1 0 1 0 0 0 0 0 1 0 0 1
1.2 1 0 0 0 0 1 0 0 0 0 1 0 -1
1.3 -1 -1 0 0 0 0 1 0 0 0 0 1 1
2.1 1 0 0 1 0 0 0 0 0 0 1 0 -1
2.2 0 0 0 0 0 0 0 1 0 1 0 0 1
2.3 0 0 0 0 1 0 0 0 0 -1 -1 -1 0
s10 eff2 eff3 eff4 accel2 accel3 accel4
1.1 0 0 0 1 1 0 0
1.2 -1 -1 -1 -1 0 0 1
1.3 0 1 0 0 -1 -1 -1
2.1 -1 0 1 0 1 0 0
2.2 0 0 1 0 -1 -1 -1
2.3 1 -1 -1 -1 0 1 0
当我运行它时,这是我得到的错误:
> mixed.est <- mlogit(choice ~ Price2 + Price3 + Price4 + Price5 + American + Japanese +
Chinese + SKorean + HEV + PHEV10 + PHEV20 + PHEV40 + EV75 + EV100 + EV150 + F20 + F30 +
FNA + s6 + s10 + eff2 + eff3 + eff4 + accel2 + accel3 + accel4|0, DATA,
rpar=c(Price2='n', Price3='n', Price4='n', Price5='n', American='n', Japanese='n',
Chinese='n', SKorean='n', HEV='n', PHEV10='n', PHEV20='n', PHEV40='n', EV75='n',
EV100='n', EV150='n', F20='n', F30='n', FNA='n', S6='n', S10='n', eff2='n', eff3='n',
eff4='n', accel2='n', accel3='n', accel4='n'), R=100, halton=NA, print.level=0, panel=F)
Error in rep(halt, prime - 1) : invalid 'times' argument