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, eval = TRUE ) options(cite = FALSE)
zelig()
accepts matched datasets from the MatchIt package as the data
argument.
suppressWarnings(suppressMessages(library(Zelig))) set.seed(1234)
First, using the MatchIt package, we attaching the lalonde
example dataset, and run matching:
library("MatchIt") data(lalonde) m.out <- matchit(treat ~ educ + black + hispan, data = lalonde, method = "optimal")
Then we can use the output object from the MatchIt package directly in the data argument for Zelig:
z.out <- zelig(educ ~ treat, model = "ls", data = m.out)
Zelig will automatically extract the dataset and the weights from the MatchIt object and use them in analysis. For more details on how weights are used in Zelig across models, see the weights section.
From the MatchIt object, it knows what matching method was used, and adds appropriate citations to the reference list accordingly, in addition to the other references it builds from models and utilities in Zelig:
print(z.out$references())
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.