Summary statistics after imputation with mice

Someone recently asked how they could calculate summary statistics after performing multiple imputation with the mice package. The first thing to say is that if you are only interested in calculating a certain summary statistic on each of the imputed datasets, this is easy to achieve. You can extract each imputed dataset using the complete() function, and then apply whatever function you would normally use to calculate the summary statistic in question.

In the rest of this post, I’ll consider the situation where you are interested in performing inference for the summary statistic (or functional if you will). That is, if you are interested in say the median in your data, you are interested because ultimately you are interested in the median of the variable in the population (from which your sample data came from). Viewed this way, the summary statistic is an estimator of a population parameter, and so we should apply the usual procedure for multiple imputation: estimate the parameter on each imputed dataset and its corresponding complete data variance, and then pool these using Rubin’s rules. For some quantities (e.g. the mean), this is pretty easy. For others, at least as far as I can see, it requires a bit more work.

Read more

smcfcs imputation in R – now with parallel functionality

Substantive model compatible fully conditional specification multiple imputation can be useful for imputing missing values in covariates in a way which accommodates the form of the substantive/outcome model. One of its drawbacks compared to standard FCS imputation, as implemented in the mice package in R, is its higher computational burden. This is due to the use of rejection sampling when imputing missing values in continuous covariates.

I am happy to announce that thanks to the efforts of Edouard Bonneville, the smcfcs package in R now supports the use of multiple cores by parallel processing. The package now has a function smcfcs.parallel. This can be used to call the other smcfcs functions in parallel. Having specified the number of imputations desired, smcfcs.parallel splits these across the number of cores/processors specified by the user in the n_core argument. Since multiple imputation is ’embarrassingly parallel’, substantial speed improvements can be achieved. Many thanks to Ed for his continuing contributions to smcfcs in R.

Multiple imputation separately by groups in R and Stata

When using multiple imputation to impute missing values there are often situations where one wants to perform the imputation process completely separately in groups of subjects defined by some fully observed variable (e.g. sex or treatment group). In Stata, this is made very easy through use of the by() option. You simply tell the mi impute command what variable (or variables) you want to perform the imputation stratified on. Stata will then impute separately in groups defined by this variable(s), and then assemble the imputations of each strata back together so you have your desired number of imputed datasets.

Last week someone asked me how to do it in R, ideally with the mice package. Compared to Stata, one has to do a little bit more work. One approach is to use the mice.impute.bygroup function in the miceadds package, a package which extends functionality for mice in various directions. If you instead want to do it manually, you can do so by making using of the rbind function within the mice package.

Read more