小鼠的直方图在R中多重估算变量
使用小鼠软件包将丢失的数据算后,我正在寻找一种使用一个估算变量之一的直方图绘制分布的方法。我可以使用以下代码来绘制“臭氧”的分布,但是每个估算的数据集(总共5个)的直方图。
我正在寻找一种创建1个直方图的方法,这是5个直方图的“汇总”结果,如果可能的话。类似于您如何汇总回归系数的如何归纳数据集,以获取系数的最终摘要。
# Example dataset
data <- airquality
# Add missing data
data[4:10,3] <- rep(NA,7)
data[1:5,4] <- NA
data <- data[-c(5,6)]
# Impute missing data creating 5 datasets
imp <- mice::mice(data,m=5,maxit=50,meth='pmm',seed=500)
# Plot distribution of "Ozone" - Results in 5 plots, Aim is one "pooled" histogram
with(imp, hist(Ozone))
After using the MICE package to impute missing data I am looking for a way to plot the distribution, using a histogram, of one of the imputed variables. I can use the following code to plot the distribution of "Ozone", however one histogram per imputed dataset (5 in total) is produced.
I am looking for a way to create 1 histogram which is the "pooled" result of the 5 histograms, if this is possible. Similar to how you would pool regression coefficients from MICE imputed datasets to get a final summary for the coefficients.
# Example dataset
data <- airquality
# Add missing data
data[4:10,3] <- rep(NA,7)
data[1:5,4] <- NA
data <- data[-c(5,6)]
# Impute missing data creating 5 datasets
imp <- mice::mice(data,m=5,maxit=50,meth='pmm',seed=500)
# Plot distribution of "Ozone" - Results in 5 plots, Aim is one "pooled" histogram
with(imp, hist(Ozone))
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用函数
merge_imputations
合并归档。您可以使用以下代码:输出:
You can use the function
merge_imputations
to merge the imputations. You can use the following code:Output: