【问题标题】:Coding random effect in mclogit在 mclogit 中编码随机效应
【发布时间】:2019-05-24 08:06:42
【问题描述】:

我正在尝试使用 R 包 mclogit 中的 mclogit 函数使用条件逻辑模型分析离散选择实验,该模型对每个受试者具有随机效应。每个主题 (ID) 对 4 个选择集进行评分,其中包含 4 个备选方案。

我得到了错误

属性错误(.Data)

当我把它编码为

out2

我希望能得到正确编码的帮助。

library(support.CEs)
library(survival)
library(mclogit)

d.pork <- Lma.design(
  attribute.names = list(
    Price = c("100", "130", "160", "190")),
  nalternatives = 3,
  nblocks = 4,
  row.renames = FALSE,
  seed = 987)

data(pork)

dm.pork <- make.design.matrix(
  choice.experiment.design = d.pork,
  optout = TRUE,
  continuous.attributes = c("Price"),
  unlabeled = FALSE)

ds.pork <- make.dataset(
  respondent.dataset = pork,
  choice.indicators =
    c("q1", "q2", "q3", "q4"),
  design.matrix = dm.pork)

ds.pork$ID<-factor(ds.pork$ID)

fm1 <- RES ~ ASC1 + Price1 + ASC2 + Price2 + ASC3 + Price3 + strata(STR)
fm2<-cbind(RES, STR) ~ ASC1 + Price1 + ASC2 + Price2 + ASC3 + Price3

out1 <- clogit(fm1, data = ds.pork)
out2 <- mclogit(fm2, random=~1|ID, data=ds.pork)

【问题讨论】:

    标签: r logistic-regression mixed-models choice


    【解决方案1】:

    错误来自使用fm2而不是直接输入公式,如

    out2 <- mclogit(cbind(RES, STR) ~ ASC1 + Price1 + ASC2 + Price2 + ASC3 + Price3, random = ~1|ID, data = ds.pork)
    

    现在还有一个错误,但现在纯粹是关于模型规范。

    【讨论】:

    • @user1375871,有帮助吗?
    猜你喜欢
    • 2020-06-30
    • 2012-10-31
    • 1970-01-01
    • 1970-01-01
    • 2012-06-22
    • 2019-02-09
    • 2021-03-25
    • 1970-01-01
    • 2013-06-06
    相关资源
    最近更新 更多