MatchBalance
function which checks if the results of this function have actually
achieved balance. If one wants to do propensity score matching, one
should estimate the propensity model before calling Match
, and
then send Match
the propensity scores to use. Match
implements the matching algorithm of Abadie and Imbens which provides
principled standard errors when matching is done with covariates or a
known propensity score. Ties are handled in a deterministic and
coherent fashion.Match(Y, Tr, X, Z = X, V = rep(1, length(Y)), estimand = "ATT", M = 1,
BiasAdj = FALSE, Weight = 1, Weight.matrix = NULL, Var.calc = 0,
weights= rep(1, length(Y)), caliper=FALSE, exact = FALSE,
sample = FALSE, tmpdir = NULL, extra.output = FALSE,
tolerance = 1e-05)
Var.calc
option,
which takes precedence.Z
matrix.X
. The default value of
1 denotes that weights are equal to the inverse of the variances. 2
denotes the MahaX
---see the Weight
option. This square matrix should
have as many columns as the number of columns of the X
Var.calc=0
which means that
homoscedasticity is assumed. For values of Var.calc > 0
,
robust variances are calculated using Var.calc
maY
which
provides observations specific weights.X
should be done. When exact matches are not found,
observations are dropped. tolerance
determines
what is considered to be an exact match.Match
creates temporary files. This directory
is by default determined by a call to the tempdir
function. In
the temporary directory, Match
part.data
and aug.data
objects returned.tolerance
are deemed to
be equal to zero.X
consists of either covariates or a known propensity score
because it takes into account the uncertainty of the matching
procedure. If an estimated propensity score is used, the
uncertainty involved in its estimation is not accounted for although the
uncertainty of the matching procedure itself still is.BiasAdj
. If BiasAdj
is not requested, this is the
same as est
.weights
. Note that the
standard error provided by se
takes into account the uncertainty
of the matching procedure while se.naive
does not. Neither
se
nor se.naive
take into account the uncertainty of
estimating a propensity score. se.naive
does
not take into account any BiasAdj
. Summary of the naive
results can be requested by setting the full=TRUE
flag when
using the summary.Match
function on the object
returned by
Match
.Match
. Three datasets are included in this list: Y
,
Tr
and X
.index.control
can be used to recover the matched dataset produced by
Match
. For example, the X
matrix used by Match
can be recovered by
rbind(X[index.treated,],X[index.control,])
. The user should
generally just examine the output of mdata
.index.treated
can be used to recover the matched dataset produced by
Match
. For example, the X
matrix used by Match
can be recovered by
rbind(X[index.treated,],X[index.control,])
. The user should
generally just examine the output of mdata
.index.treated
, but
the index that would be produced without a caliper. This
is exactly the same as index.treated
if no caliper was used.index.control
, but
the index that would be produced without a caliper. This
is exactly the same as index.control
if no caliper was used.extra.output
flag for compatibility with Imbens's function.extra.output
flag for compatibility with Imbens's function.MatchBalance
function which checks if the results of this
function have actually achieved balance. The results of this function
can be summarized by a call to the summary.Match
function. If one wants to do propensity score matching, one should estimate the
propensity model before calling Match
, and then place the
fitted values in the X
matrix---see the provided example.
Three demos are included: GerberGreenImai
, DehejiaWahba
,
and AbadieImbens
. These can be run by calling the
demo
function such as by demo(DehejiaWahba)
.summary.Match
, MatchBalance
,
balanceMV
, balanceUV
,
GerberGreenImai
, lalonde
#
# Replication of Dehejia and Wahba psid3 model
#
# Dehejia, Rajeev and Sadek Wahba. 1999.``Causal Effects in Non-Experimental Studies: Re-Evaluating the
# Evaluation of Training Programs.''Journal of the American Statistical Association 94 (448): 1053-1062.
#
data(lalonde)
#
# Estimate the propensity model
#
glm1 <- glm(treat~age + I(age^2) + educ + I(educ^2) + black +
hisp + married + nodegr + re74 + I(re74^2) + re75 + I(re75^2) +
u74 + u75, family=binomial, data=lalonde)
#
#save data objects
#
X <- glm1$fitted
Y <- lalonde$re78
Tr <- lalonde$treat
#
# one-to-one matching with replacement (the "M=1" option).
# Estimating the treatment effect on the treated (the "estimand" option which defaults to 0).
#
rr <- Match(Y=Y,Tr=Tr,X=X,M=1);
summary(rr)
#
# Let's check for balance
# 'nboots' and 'nmc' are set to small values in the interest of speed.
# Please increase to at least 500 each for publication quality p-values.
mb <- MatchBalance(treat~age + I(age^2) + educ + I(educ^2) + black +
hisp + married + nodegr + re74 + I(re74^2) + re75 + I(re75^2) +
u74 + u75, data=lalonde, match.out=rr, nboots=10, nmc=10)
Run the code above in your browser using DataLab