我正在尝试在模型中使用动态协变量(取自用户输入)lmer
。这工作正常,但应用emmeans
不再工作。
例子:
fit1 = lmer(get(uservar) ~ Intervention + period + sequence + age + (1|ID),
data = mydata, REML=T)
和
emmeans(fit1, list(pairwise ~ Intervention), adjust = "tukey")
运行没有问题。
lmer(get(uservar) ~ Intervention + period + sequence + get(covariable) + (1|ID),
data = mydata, REML=T)
"age"
从用户输入弹出框中获取协变量也可以。
但:
emmeans(fit1, list(pairwise ~ Intervention), adjust = "tukey")
不再运行。它在说:
变量有不同的长度(为“协变量”找到)
但事实并非如此。如果我检查mydata[,covariable]
它的长度与其他变量相同。
有什么建议该怎么做吗?