首页 > 解决方案 > 使用 mitml、nlme 和 geepack R 包进行多重插补后获得估计均值

问题描述

我正在通过包mitml(使用函数)运行多级多重插补,并通过包和panimpute()函数拟合线性混合模型和边际模型。nlmegeepackmitml:with()

我可以通过该函数获得估计值、p 值等,testEstimates()但我也希望在我的模型预测变量中获得估计均值。我已经尝试过这个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))

标签: rnlmeemmeansmi

解决方案


推荐阅读