我正在尝试使用R包
当我将代码写成以下形式时,
mclogit
中的条件Logistic模型和每个受试者的随机效应来分析离散选择实验。每个受试者(ID)评估了4个选择集,每个选择集包含4个备选项。当我将代码写成以下形式时,
我遇到了以下错误:out2 <- mclogit(fm2, random=~1|ID, data=ds.pork)
我希望得到正确编码的帮助。Error in attributes(.Data) <- c(attributes(.Data), attrib) : cannot set attribute on a symbol
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)