Built using Zelig version r packageVersion("Zelig")

knitr::opts_knit$set(
    stop_on_error = 2L
)
knitr::opts_chunk$set(
    fig.height = 11,
    fig.width = 7
)

options(cite = FALSE)

zelig() accepts multiply imputed data output objects from the Amelia package as the data argument.

suppressWarnings(suppressMessages(library(Zelig)))
suppressWarnings(suppressMessages(library(methods)))
set.seed(1234)

First, using the Amelia package, we multiply impute a dataset with missing values:

library("Amelia")
data(africa)
a.out <- amelia(x = africa, cs = "country", ts = "year", logs = "gdp_pc")

Then we can use the output object from the Amelia package directly in the data argument for Zelig:

z.out <- zelig(gdp_pc ~ trade + civlib, model = "ls", data = a.out)

Zelig will automatically extract the imputed datasets from the Amelia object, and run the requested model in each of them. When the estimated model parameters are summarized, the results from each imputed dataset are available, but more importantly, the combined answer across the imputed datasets calculated by "Rubin's Rules" are automatically presented:

summary(z.out)

To see the result from an individual imputed dataset, we use the subset argument as:

summary(z.out, subset = 2:3)

When quantities of interest are plotted, such as expected and predicted values and first differenences, these are correctly pooled across those from each of the m imputed datasets:

z.out$setx()
z.out$sim()
plot(z.out)

Other multiply imputed data

Zelig also includes a function called from_zelig_model() to conform multiply imputed data sets from other sources to a form that zelig can use.



IQSS/Zelig documentation built on Dec. 11, 2023, 1:51 a.m.