[R-sig-ME] Linear mixed modeling following multiple imputation.

W Robert Long longrob604 at gmail.com
Mon Dec 3 20:06:28 CET 2012


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:
> Hello,
>
> I have a question that may require expertise outside of the domains covered
> by this listserve.  I apologize if this question is not relevant here. I
> would appreciate any help, or a suggestion of where to find an answer to
> this question.
>
> I was recently asked to conduct multiple imputation using the Amelia
> procedure in R on a longitudinal data set (102 human participants with data
> measured at 5 time-points for each participant). I would like to conduct
> linear mixed modeling on the imputed data sets and pool the results.
>
> My code for the linear mixed modeling is as follows:
>
> diff <- lmer(trans1 ~ time*negative + (time | Subject), data = set1)
> cftest (diff)
>
> Here, (I think) I am predicting the intercept and slope of trans1
> (=substance use over time) from the fixed effects of negative (=negative
> emotion at baseline - i.e., the first time-point).
>
> It is stated in the Amelia manual that to properly analyze data (e.g.,
> taking into account error variance associated with the imputation process
> itself), "...users could simply program a loop over the number of
> imputations and run the analysis model on each imputed dataset and combine
> the results using the rules described in King et al. (2001) and Schafer
> (1997)."  This is where I am stuck. I am able to obtain the imputed data
> sets using the Amelia code, but do not know how to write the code to
> program a loop over the imputed data sets and combine the results.  I have
> very little experience coding in R and do not know where to begin to look
> to find out how to do this.
>
> Any help is much appreciated.
>
> Thanks,
> Matt
>
> 	[[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-mixed-models at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
>



More information about the R-sig-mixed-models mailing list