mlogit:具有拦截的多项式概率模型返回错误

时间:2019-02-28 12:36:11

标签: r statistics multinomial mlogit

我在将mlogit软件包与多项式概率拟合时遇到问题。

我对具有单个替代特定协变量和泛型系数的模型感兴趣(有关符号here的更多详细信息)。简而言之,2001年的受访者面临6个选择。每个受访者都拥有与每个选项相关的效用得分。选择的分布来自真实数据,但出于此练习的目的,效用得分(以0到100为单位)是随机生成的,以避免多重共线性。由于选择场景是真实的,因此估计了具有截距的模型。

完整数据可用here,并且可以使用将数据转换为长格式的代码here。我在下面提供了head的原始数据,随后将其转换为长格式。

#准备样品数据

    library(mlogit)
    data_head<-head(original_data) ##from https://pastebin.com/28XpX7A4
    DT_head_long <- mlogit.data(data_head, shape="wide", varying=1:6, choice="choice_with_6_alternative")  

   DT_head_long<-structure(list(choice_with_6_alternative = c(FALSE, FALSE, FALSE, 
    TRUE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, 
    FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, 
    TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, 
    FALSE, FALSE, FALSE, TRUE, FALSE, FALSE), alt = c(1, 2, 3, 4, 
    5, 6, 1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6, 1, 
    2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6), random_utility = c(18, 25, 
    12, 13, 2, 37, 3, 21, 38, 3, 6, 51, 8, 33, 32, 9, 6, 29, 43, 
    6, 5, 25, 15, 17, 24, 11, 12, 29, 33, 13, 16, 22, 12, 5, 21, 
    3), chid = c(1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 
    3L, 3L, 3L, 3L, 3L, 3L, 4L, 4L, 4L, 4L, 4L, 4L, 5L, 5L, 5L, 5L, 
    5L, 5L, 6L, 6L, 6L, 6L, 6L, 6L)), reshapeLong = list(varying = structure(list(
    random_utility = c("random_utility.1", "random_utility.2", 
    "random_utility.3", "random_utility.4", "random_utility.5", 
    "random_utility.6")), v.names = "random_utility", times = c(1, 
    2, 3, 4, 5, 6)), v.names = "random_utility", idvar = "chid", 
    timevar = "alt"), row.names = c("1.1", "1.2", "1.3", "1.4", 
    "1.5", "1.6", "2.1", "2.2", "2.3", "2.4", "2.5", "2.6", "3.1", 
    "3.2", "3.3", "3.4", "3.5", "3.6", "4.1", "4.2", "4.3", "4.4", 
    "4.5", "4.6", "5.1", "5.2", "5.3", "5.4", "5.5", "5.6", "6.1", 
    "6.2", "6.3", "6.4", "6.5", "6.6"), class = c("mlogit.data", 
    "data.frame"), index = structure(list(chid = structure(c(1L, 
    1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 
    3L, 4L, 4L, 4L, 4L, 4L, 4L, 5L, 5L, 5L, 5L, 5L, 5L, 6L, 6L, 6L, 
    6L, 6L, 6L), .Label = c("1", "2", "3", "4", "5", "6"), class = "factor"), 
    alt = structure(c(1L, 2L, 3L, 4L, 5L, 6L, 1L, 2L, 3L, 4L, 
    5L, 6L, 1L, 2L, 3L, 4L, 5L, 6L, 1L, 2L, 3L, 4L, 5L, 6L, 1L, 
    2L, 3L, 4L, 5L, 6L, 1L, 2L, 3L, 4L, 5L, 6L), .Label = c("1", 
    "2", "3", "4", "5", "6"), class = "factor")), class = "data.frame", row.names = c("1.1", 
    "1.2", "1.3", "1.4", "1.5", "1.6", "2.1", "2.2", "2.3", "2.4", 
    "2.5", "2.6", "3.1", "3.2", "3.3", "3.4", "3.5", "3.6", "4.1", 
    "4.2", "4.3", "4.4", "4.5", "4.6", "5.1", "5.2", "5.3", "5.4", 
    "5.5", "5.6", "6.1", "6.2", "6.3", "6.4", "6.5", "6.6")), choice = "choice_with_6_alternative")

#probit = TRUE拟合模型

probit <- mlogit(choice_with_6_alternative ~ random_utility, 
  data=DT_head_long, 
  probit=TRUE)

//The model returns the error: 

Error in if (is.null(initial.value) || lnl <= initial.value) break : 
  missing value where TRUE/FALSE needed

#probit = FALSE拟合模型

//model without intercept: runs well
    probit <- mlogit(choice_with_6_alternative ~ random_utility|0, 
      data=DT_head_long, 
      probit=FALSE)

//model with intercept: runs well
    logit <- mlogit(choice_with_6_alternative ~ random_utility, 
      data=DT_head_long, 
      probit=FALSE)

#我的问题:

1-与错误有关的是什么?
  2-模型不明?

0 个答案:

没有答案