问题描述
我想在离散选择数据集上运行mlogit函数。下面,我利用产生错误的软件包mlogit提供了数据和R代码行。运行有关mlogit.data维度的完整数据集时出现错误。在运行mlogit时,我将“选择”变量强制为逻辑错误。
这是代码的快照以及用于在R中重现其子集的结构。
structure(list(row_id = c("1a","1b","1c","1d","1e","1g"),choice = structure(c(2L,1L,2L,1L),.Label = c("1","2"),class = "factor"),alt_var = structure(c(1L,2L),meal_choice = structure(c(1L,transport_choice = structure(c(1L,packaging_source = structure(c(1L,disposal_choice = structure(c(1L,class = "factor")),row.names = c(NA,-6L),class = c("data.table","data.frame"),.internal.selfref = <pointer: 0x7fa6d980f8e0>)
mlogit.data(data = df,choice = "choice",shape = "long",alt.var = "alt_var",id.var = "row_id",drop.index = TRUE)
Error in `$<-.data.frame`(x,name,value) : replacement has 964 rows,data has 965
mlogit(choice ~ meal_choice + transport_choice + packaging_source + disposal_choice,df,reflevel = "car")
`Error in dfidx::dfidx(data = data,dfa$idx,drop.index = dfa$drop.index,:
impossible to coerce the choice variable to a logical`
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)