我正在使用
我可以通过
这是我的代码:
mitml
包(使用panimpute()
函数)运行多层多重插补,并通过nlme
和geepack
软件包以及mitml:with()
函数来拟合线性混合模型和边缘模型。我可以通过
testEstimates()
函数获得这些估计值、p值等,但我还想获得模型预测变量的估计均值。我尝试了emmeans
包,通常在没有多重插补时,我会使用它来获取nlme & geepack
的估计均值,但这样做时,emmeans告诉我“无法处理“mitml.result”类的对象”。
我想知道是否有办法从我运行的多重插补分析中获取汇总的估计均值?
我正在分析的数据框是纵向/重复测量的,并且是长格式的。在线性混合模型中,我想要获取2x2交互效应的估计均值,在边际模型中,我试图获取“时间”变量的6个水平的估计均值。所有模型的结果都是连续的。这是我的代码:
# mixed model
fml <- Dep + time ~ 1 + (1|id)
imp <- panImpute(data=Data, formula=fml, n.burn=50000, n.iter=5000, m=100, group = "treatment")
summary(imp)
plot(imp, trace="all")
implist <- mitmlComplete(imp, "all", force.list = TRUE)
fit <- with(implist, lme(Dep ~ time*treatment, random = ~ 1|id, method = "ML", na.action = na.exclude, control = list(opt = "optim")))
testEstimates(fit, var.comp = TRUE)
confint.mitml.testEstimates(testEstimates(fit, var.comp = TRUE))
# marginal model
fml <- Dep + time ~ 1 + (1|id)
imp <- panImpute(data=Data, formula=fml, n.burn=50000, n.iter=5000, m=100)
summary(imp)
plot(imp, trace="all")
implist <- mitmlComplete(imp, "all", force.list = TRUE)
fit <- with(implist, geeglm(Dep ~ time, id = id, corstr ="unstructured"))
testEstimates(fit, var.comp = TRUE)
confint.mitml.testEstimates(testEstimates(fit, var.comp = TRUE))