使用mitml、nlme和geepack R包进行多重插补后获取估计值

4
我正在使用mitml包(使用panimpute()函数)运行多层多重插补,并通过nlmegeepack软件包以及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))
1个回答

0
有没有办法从我运行的多重插补分析中获取汇总的估计均值?
这不是一个没有数据的reprex,所以我无法验证它是否适用于您。但是emmeans支持mice软件包中miraclass(列表)模型。因此,如果您在with()中使用mids而不是mitml.list类对象拟合模型,则可以使用它来获得结果的边际均值(以及任何之后的对比或成对比较)。
使用 here 找到的示例数据,这会不舒服地加载外部工作区:
con <- url("https://www.gerkovink.com/mimp/popular.RData")
load(con)

## imputation

library(mice)

ini <- mice(popNCR, maxit = 0)
meth <- ini$meth
meth[c(3, 5, 6, 7)] <- "norm"

pred <- ini$pred
pred[, "pupil"] <- 0

imp <- mice(popNCR, meth = meth, pred = pred, print = FALSE)


## analysis

library(lme4) # fit multilevel model
mod <- with(imp, lmer(popular ~ sex + (1|class)))

library(emmeans) # obtain pooled estimates of means
(em <- emmeans(mod, specs = ~ sex) )
pairs(em) # test comparison

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接