使用 R 中的 mouse 包进行多重插补的残差图

标签 r statistics missing-data r-mice

使用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/

相关文章:

r - 如何在 R 中将密度表示为百分比?

sql - 如何使用 mssql 获取每月每一天的值(value)

python - Pandas:通过每组的加权平均值填充缺失值

r - 将具有交替缺失值的两个字符串列合并为一个

R openNLP 找不到函数 sentDetect()

r - 有没有办法使用R中的summary函数来计算重复观察值?

r - R 中 xts 对象的条件语句

matlab - 如何在 Matlab 中显示 100x1 矢量数据的经验 pdf?

r - knit 命令不起作用而 knit HTML 按钮起作用

python - 缺失值屏蔽数组相关性 (numpy.ma)