R:mlogit-错误“假名”应用于非数组

时间:2018-11-28 14:26:55

标签: r names mlogit

我正在尝试分析离散选择实验中的选择数据。运行mlogit()函数时出现以下错误:

  

dimnames(P)中的错误<-dimnames(Xb)<-list(attr(y,“ chid”),   names(y)):'dimnames'应用于非数组

以下是复制错误的代码:

test <- data.frame(
  id = rep(1:10,each=100),
  instance = rep(1:500,each=2),
  choice = c(rep(c(1,0),150),rep(c(0,1),200),rep(c(0,0),150)),
  rating = sample(1:4,1000,replace=T),
  brand = sample(c("A","B","C"),1000,replace=T),
  price = sample(1:5000,1000,replace=T)
  ) 
mlogitformat.test <- mlogit.data(data=test, shape = "long", choice = "choice", id.var = "id", alt.levels = "instance", varying = 4:6)
model.test <- mlogit(choice ~ 0 + rating + brand + price, mlogitformat.test)

我想念什么?

0 个答案:

没有答案