An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-sig-mixed-models/attachments/20121203/62a4691c/attachment.pl>
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:
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
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:
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
_______________________________________________ R-sig-mixed-models at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-sig-mixed-models/attachments/20121204/6a4d83cb/attachment.pl>