How can I perform an operation (like subsetting or adding a calculated column) on each imputed dataset in an object of class mids
from R's package mice
? I would like the result to still be a mids
object.
Edit: Example
library(mice)
data(nhanes)
# create imputed datasets
imput = mice(nhanes)
The imputed datasets are stored as a list of lists
imput$imp
where there are rows only for the observations with imputation for the given variable.
The original (incomplete) dataset is stored here:
imput$data
For example, how would I create a new variable calculated as chl/2
in each of the imputed datasets, yielding a new mids
object?
imput$data
, but it's separate from the imputed datasets. I just added an example with this.chl/2
you can calculate this before the imputation. Than when doing the imputation you add the restriction that when any imputation of missing for this column equalschl/2