使用mice
包,我们如何检查合并分析的残差?
library(mice)
imp <- mice(nhanes, seed = 23109)
fit <- with(imp, lm(chl ~ age + bmi))
pool(fit)
summary(pool(fit))
fit
包含对每个估算数据集的分析以及pool(fit)
汇总结果。是否有一个命令可以检查标准 lm
对象的残差,例如 plot(pool(fit))
?
最佳答案
我遇到了同样的问题,并用一个非常详尽的解决方案解决了它。我保存了每个单独的估算数据集的残差和拟合值。如果您只有有限数量的数据集,这可以正常工作,但如果您有更多数据集,这会变得更加复杂(我有 75 个,所以我的脚本变得很长)。 我将基于具有 5 个估算数据集的示例来解释我的解决方案:
# Computing and saving the mean residual per individual over 5 imputed datasets
RS1 <-residuals(model1$ana[[1]])+residuals(model1$ana[[2]])+residuals(model1$ana[[3]])+residuals(model1$ana[[4]])+residuals(model1$ana[[5]])
RSmodel1 <- RS1 / 5
# Computing and saving the mean predicted value per individual over 5 imputed datasets
PS1 <-predict(model1$ana[[1]])+predict(model1$ana[[2]])+predict(model1$ana[[3]])+predict(model1$ana[[4]])+predict(model1$ana[[5]])
PSmodel1 <- PS1 / 5
# Creating the residual plot
plot(RSmodel1, PSmodel1)
希望这对您有帮助! 我很清楚我的解决方案非常不方便,但它可以完成工作:)
关于使用 R 中的 mouse 包进行多重插补的残差图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33859440/