Skip to content
Prev 13010 / 20628 Next

Best way to handle missing data?

Thanks for this suggestion, Malcolm.  Here is an example in which I use
Amelia/Zelig with the "africa" data set that is available in Amelia.
I extracted the average standard deviation of the random effects from the
result produced by Zelig.  (In this example, I am using the version of the
summary.MI function found here:
http://stackoverflow.com/questions/16571580/multi-level-regression-model-on-multiply-imputed-data-set-in-r-amelia-zelig-l)
 Perhaps this approach will work for my purposes.

# Get packages
require(Amelia)
require(Zelig)
require(ZeligMultilevel)

# Look at the data
data(africa)
head(africa)
summary(africa)
help(africa)

# Impute the missing data
africa.am <-
  amelia(x = africa,
         m = 30,
         cs = "country",
         ts = "year",
         logs = "gdp_pc")
summary(africa.am)
plot(africa.am)
missmap(africa.am)
names(africa.am)

# Create a model:
africa.z <-
  zelig(formula = gdp_pc ~ infl + tag(infl | country),
        data = africa.am$imputations,
        model = "ls.mixed")

# The combined fixed effects:
summary(africa.z)

# The average standard deviation of the random intercepts and slopes:
ran.ints <-
  sapply(africa.z,
         function(x)
           attributes(VarCorr(x$result)$country)$stddev["(Intercept)"])
mean(ran.ints)

ran.slopes <-
  sapply(africa.z,
         function(x)
           attributes(VarCorr(x$result)$country)$stddev["infl"])
mean(ran.slopes)



On Fri, Feb 27, 2015 at 4:47 AM, Malcolm Fairbrother <
M.Fairbrother at bristol.ac.uk> wrote: