I need to add variables to the imputed data sets built with mice() , and then use as.mids() to collect them into a mids object for later analysis. However, when I use complete() on the restored mids object, I find that many of the values ββof the new variable added to the dataset become NA.
library(mice) d1 = as.data.frame(matrix(rnorm(100), nrow = 10)) missingness = matrix(as.logical(rbinom(100,1,.2)), ncol = 10) d1[which(missingness, arr.ind = T)] = NA
In the above example, I created a new long data.frame and applied as.mdids() to it, but I get the same results if I use cbind to add a new variable to d.long , or if I assign a new variable << 29 >.
How can I make sure that the values ββin the new variable remain there after the mids object is mids ?
source share