Skip to content

Linear mixed modeling following multiple imputation.

4 messages · Matthew Boden, Robert Long, Dennis Murphy +1 more

#
I haven't used Amelia before, but I have done multiple imputation, using 
the mice package, followed by linear mixed models. I see on p13 of 
http://r.iq.harvard.edu/docs/amelia/amelia.pdf that write.amelia() 
outputs a csv file of each completed dataset. There may be a more direct 
way to access the completed datasets but something like this should work:

write.amelia(obj=a.out, file.stem = "outdata")

diff <-list(m)  # a list to store each model

for (i in 1:m) {
	file.name <- paste("outdata", m ,".csv",sep="")
	data.to.use <- read.csv(file.name)
	diff[[m]] <- lmer(trans1 ~ time*negative + (time | Subject), +
	data = data.to.use )
}

Here m is the number of imputed datasets.

Does Amelia handle the multilevel/clustered aspect of your data ? mice 
has some basic multilevel imputation capabilities but perhaps I should 
take a closer look at Amelia. This is actually of great interest to me.

Hope it helps
Rob
On 03/12/2012 18:23, Matthew Boden wrote:
#
Hi:

After imputation via amelia(), the output file is a list whose first
component, imputations, is a list containing the imputed data frames.
Given that the post-imputation object is named a.out, one can write
the list of imputed data frames as  a.out$imputations, from which the
models can be fit with

library(lme4)
mods <- lapply(a.out$imputations,
                function(d) lmer( trans1 ~ time*negative + (time | Subject),
                                                data = d ) )

This avoids the step of saving the individual imputed data sets to
disk and reading them back in.

Dennis
On Mon, Dec 3, 2012 at 11:06 AM, W Robert Long <longrob604 at gmail.com> wrote: