Here is an example of using a created data set on how to analyze imputed survey data in R with mitools, Ameila and the survey packages.

First, we start by using the library function to library all of the packages and create the data set with missing data.

library(mitools)
library(Amelia)
library(survey)
data = data.frame(a = rnorm(100), b = rnorm(100), w = abs(rnorm(100)))
data[2:4,1] = NA
data[8:10, 2] = NA
head(data, 10)
##              a           b         w
## 1   0.08752061  1.01434121 1.4975244
## 2           NA  0.86803755 1.8244778
## 3           NA  0.02410824 0.7319917
## 4           NA  1.03999462 1.9854642
## 5   0.32823837 -1.23985003 1.0841668
## 6  -0.14174027  0.43067859 0.3731127
## 7  -1.18453181  0.25413842 1.7094252
## 8  -0.74207891          NA 0.1060560
## 9  -0.52934155          NA 0.3118926
## 10  0.51462081          NA 0.4643704

Now we are going to impute the missing values in the example data set, by running the data set through the amelia function setting x equal to the data set and m equal to the number of imputed data sets we desire, five in this example.

Then we need to grab the imputed data sets from the a.out object we created above, which are located in a.out$imputations, and transform these imputed data sets into an imputation list that the survey package and mitools can read.

m <- 5
a.out <- amelia(x = data, m=m)
## -- Imputation 1 --
## 
##   1  2  3  4
## 
## -- Imputation 2 --
## 
##   1  2  3  4
## 
## -- Imputation 3 --
## 
##   1  2  3
## 
## -- Imputation 4 --
## 
##   1  2  3
## 
## -- Imputation 5 --
## 
##   1  2  3
a.out.imp = imputationList(a.out$imputations)

Next, we can create the survey design object, with the svydesign command. For this data, there is no id so we use the value 1, which indicates now no id value, we set the weights to w, and the data as the imputed data sets that were transformed into an imputation list, a.out.imp.

Now we can appropriately weight the survey statistics and parameter estimates that we want to analyze. To do this we need to use the with command, starting with the survey design object, designs in this example, and then select the analysis we want. Below we have an analysis extracting the mean for the variable a and a bivariate regression with the imputed data sets and appropriate survey weights.

Finally, we can combine the results from the analyses, the mean of a and a bivariate regression of a on b in this example, using the MIcombine function in the mitools package to appropriately combine the results from the five imputed data sets into one mean and one set of parameter estimates in this example.

designs<-svydesign(id =~ 1, weights =~ w, data=a.out.imp)
testMeans = MIcombine(with(designs, svymean(~a)))
testMeans
## Multiple imputation results:
##       with(designs, svymean(~a))
##       MIcombine.default(with(designs, svymean(~a)))
##      results        se
## a -0.1097927 0.1302424
model1 = with(designs, svyglm(a ~ b)) 
summary(MIcombine((model1)))
## Multiple imputation results:
##       with(designs, svyglm(a ~ b))
##       MIcombine.default((model1))
##                results        se     (lower    upper) missInfo
## (Intercept) -0.1117568 0.1299119 -0.3667918 0.1432782      8 %
## b           -0.1567409 0.1504161 -0.4519213 0.1384395      7 %