Not sure exactly what you want to do. Are you trying to get the mean for
each obs across the five datasets? Then you can just use aggregate for
example or lappy. You can also do it in an array.
Here is an example with two datasets:
x1 <- data.frame(ind = 1:10, a = 1:10, beta = exp(1:10), logic =
rep(c(TRUE,TRUE,FALSE,FALSE,TRUE),2));
x2 <- data.frame(ind = 1:10, a = 11:20, beta = log(1:10), logic =
.5*rep(c(TRUE,TRUE,FALSE,FALSE,TRUE),2));
store <- rbind(x1,x2);
aggregate(store[,-1],by=list(ind=store$ind),mean);
From: gov2001-l-bounces at
lists.fas.harvard.edu
[mailto:gov2001-l-bounces at
lists.fas.harvard.edu] On Behalf Of Brett Logan
Carter
Sent: Saturday, April 26, 2008 9:14 PM
To: gov2001-l at
lists.fas.harvard.edu
Subject: [gov2001-l] Simulation with multiply imputed data sets
Hi everyone,
I have a quick question. I'm working with several multiply imputed data sets
and would like to simulate quantities of interest at mean/mode values of
explanatory variables. Because of the way I subset data iteratively in a for
loop, I would like to consolidate the five data sets into a single data set,
with each observation simply taking the mean (or, in some cases, mode) value
of the five data cells from the imputed data sets.
So my question: How can I coerce the five imputed data sets into a single
data set with mean/mode values? There must be some straightforward way to do
this.
Thanks in advance for the help. Best,
Brett