[英]How can I use rowSums() after multiple imputation with MICE package in R
I have a short question:我有一个简短的问题:
I imputed item data using multiple imputation with the MICE package.我使用 MICE 包的多重插补来插补项目数据。
After imputation, I would like to sum items to a total score.插补后,我想将项目总和为总分。
However, my data is now in a mids object, and I can't figure out how to do this simple task.但是,我的数据现在位于 mids 对象中,我无法弄清楚如何完成这个简单的任务。
Does anyone have experience with this "problem"?有没有人有这个“问题”的经验?
Best, Leonhard最好的,莱昂哈德
I figured it out:我想到了:
Example code:示例代码:
# load .mids object
library("miceadds")
Dmi<-load.Rdata2("imp.Rdata",paste(getwd(),"imp",sep=""))
# create object that contains all imputed datasets and the original dataset
D<-complete(Dmi,"long",include=T)
# use rowSums
D$T<-rowSums(D[2:11])
# reconstruct .mids object
Dmi<-as.mids2(D)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.