R2MLwiN and multilevel multiple imputation

Welcome to the forum for R2MLwiN users. Feel free to post your question about R2MLwiN here. The Centre for Multilevel Modelling take no responsibility for the accuracy of these posts, we are unable to monitor them closely. Do go ahead and post your question and thank you in advance if you find the time to post any answers!

Go to R2MLwiN: Running MLwiN from within R >> http://www.bris.ac.uk/cmm/software/r2mlwin/
Post Reply
tjsduq64
Posts: 17
Joined: Mon Jul 15, 2019 10:04 pm

R2MLwiN and multilevel multiple imputation

Post by tjsduq64 »

Hi,

I have a simple question, but didn't want to dive in before I know the answer to... what's the ideal approach to conduct multiple imputations of multilevel data in R using R2MLwiN? I know there are options like REALCOM and Stat-JR but I do not have access to these software. Also, it would be much simpler if I can do this in R.

Can R2MLwiN work with a package mice? I will run a two-level random slope model, and my parameters of interest are random effect parameters. Specifically, I am interested in the level 2 variance estimate as a function of a predictor. If not, are there other packages that work well with R2MLwiN?

If not, do you suggest using lme4, instead of R2MLwiN?

Thanks,

Sun

ChrisCharlton
Posts: 1147
Joined: Mon Oct 19, 2009 10:34 am

Re: R2MLwiN and multilevel multiple imputation

Post by ChrisCharlton »

The Realcom-Impute software is free to download, however converting the data to the right formats is easiest if you have MLwiN or Stata.

R2MLwiN has worked in the past with mice (see https://www.cmm.bristol.ac.uk/forum/vie ... php?t=2404), however I believe that recent versions rely on the broom package to extract the parameters, which the currently released version of R2MLwiN does not link to. I do have a local development version of R2MLwiN which does output broom-compatible objects.

In terms of using R2MLwiN to impute the missing data see chapter 18 of the MCMC guide, along with the R replication example on http://bristol.ac.uk/cmm/software/r2mlwin/examples/.

tjsduq64
Posts: 17
Joined: Mon Jul 15, 2019 10:04 pm

Re: R2MLwiN and multilevel multiple imputation

Post by tjsduq64 »

Thanks Chris.

It seems like, if I want to use R2MLwiN, my options are running a RIGLS model with Realcom or with mice. Does MCMC work with Realcom or mice? It seems like Realcom won't work, and I am not sure if mice takes mlwinMCMC object. I may need to use MCMC since my outcome is a binary variable.

Sun

ChrisCharlton
Posts: 1147
Joined: Mon Oct 19, 2009 10:34 am

Re: R2MLwiN and multilevel multiple imputation

Post by ChrisCharlton »

Could you please try running the following example to check that this works for you? If not then I can provide a development version package. Of course you could substitute your own preferred packages for the imputation and/or model of interest analysis.

Code: Select all

library(R2MLwiN)
library(mitools)
library(mice)
data(hungary1)

# Impute responses at iterations 0, 1000, 2000, 3000, 4000 and 5000
(impmodel <- runMLwiN(c(es_core, biol_core, biol_r3, biol_r4, phys_core, phys_r2) ~ 1 + female + (1 | school) + (1 | student),
 D = "Multivariate Normal", estoptions = list(EstM = 1, mcmcMeth = list(dami = c(0, 1000, 2000, 3000, 4000, 
  5000))), data = hungary1))

# Create complete datasets as imputationLIst
mi <- imputationList(impmodel@imputations)

# Fit a model to each imputated dataset
moimodels <- with(mi, runMLwiN(Formula = es_core ~ 1 + biol_core + biol_r3 + biol_r4 + phys_core + phys_r2 + femaleFemale + (1 | school) + (1 | student) ))

# Summarise model results 
summary(pool(moimodels))

Post Reply