View source: R/rbind.matchdata.R
rbind.matchdata | R Documentation |
These functions are rbind()
methods for objects resulting from calls to
match.data()
and get_matches()
. They function nearly identically to
rbind.data.frame()
; see Details for how they differ.
## S3 method for class 'matchdata'
rbind(..., deparse.level = 1)
## S3 method for class 'getmatches'
rbind(..., deparse.level = 1)
... |
Two or more |
deparse.level |
Passed to |
rbind()
appends two or more datasets row-wise. This can be useful
when matching was performed separately on subsets of the original data and
they are to be combined into a single dataset for effect estimation. Using
the regular data.frame
method for rbind()
would pose a
problem, however; the subclass
variable would have repeated names
across different datasets, even though units only belong to the subclasses
in their respective datasets. rbind.matchdata()
renames the
subclasses so that the correct subclass membership is maintained.
The supplied matched datasets must be generated from the same original dataset, that is, having the same variables in it. The added components (e.g., weights, subclass) can be named differently in different datasets but will be changed to have the same name in the output.
rbind.getmatches()
and rbind.matchdata()
are identical.
An object of the same class as those supplied to it (i.e., a
matchdata
object if matchdata
objects are supplied and a
getmatches
object if getmatches
objects are supplied).
rbind()
is called on the objects after adjusting the variables so that the
appropriate method will be dispatched corresponding to the class of the
original data object.
Noah Greifer
match.data()
, rbind()
See vignettes("estimating-effects")
for details on using
rbind()
for effect estimation after subsetting the data.
data("lalonde")
# Matching based on race subsets
m.out_b <- matchit(treat ~ age + educ + married +
nodegree + re74 + re75,
data = subset(lalonde, race == "black"))
md_b <- match.data(m.out_b)
m.out_h <- matchit(treat ~ age + educ + married +
nodegree + re74 + re75,
data = subset(lalonde, race == "hispan"))
md_h <- match.data(m.out_h)
m.out_w <- matchit(treat ~ age + educ + married +
nodegree + re74 + re75,
data = subset(lalonde, race == "white"))
md_w <- match.data(m.out_w)
#Bind the datasets together
md_all <- rbind(md_b, md_h, md_w)
#Subclass conflicts are avoided
levels(md_all$subclass)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.