help kmatchSyntax - Description - Options - Examples - Stored results - References

Title

kmatch -- Multivariate-distance and propensity-score matching, including
entropy balancing, inverse probability weighting, (coarsened) exact matching,
and regression adjustment

Syntax

Multivariate-distance matching

kmatch md
tvar [xvars]
[(ovars [= avars]) ...]
[if] [in] [weight]
[,
md_options
]

Propensity-score matching

kmatch ps
tvar [xvars]
[(ovars [= avars]) ...]
[if] [in] [weight]
[,
ps_options
]

(Coarsened) Exact matching

kmatch em
tvar [emvars]
[(ovars [= avars]) ...]
[if] [in] [weight]
[,
em_options
]

Entropy balancing

kmatch eb
tvar [xvars]
[(ovars [= avars]) ...]
[if] [in] [weight]
[,
eb_options
]

Inverse probability weighting (IPW)

kmatch ipw
tvar [xvars]
[(ovars [= avars]) ...]
[if] [in] [weight]
[,
ipw_options
]

Regression adjustment (RA)

kmatch ra
tvar
[(ovars [= avars]) ...]
[if] [in] [weight]
[,
ra_options
]

tvar is the treatment variable; xvars
and emvars
are covariates to be matched/balanced; ovars are outcome
variables; avars are adjustment variables. Multiple
outcome equations may be specified. xvars and avars may
contain factor variables; emvars
may contain coarsening rules; pweights, iweights,
and fweights are allowed, see help weight.

Bandwidth selection plot

kmatch cvplot [numlist] [, cvplotopts] (display
MISE by evaluation points)

where numlist specifies the values of the over-groups to be included
in the graph. The default is to include all over-groups.

Balancing diagnostics

kmatch summarize [varlist] [, sumopts] (means
and variances in raw and balanced data)

kmatch density [varlist] [, gropts] (kernel
density plots for raw and balanced data)

kmatch cumul [varlist] [, gropts] (cumulative
distribution plots for raw and balanced data)

kmatch box [varlist] [, gropts] (box plots
for raw and balanced data)

Common-support diagnostics

kmatch csummarize [varlist] [, sumopts] (common-support
means and variances)

kmatch cdensity [varlist] [, gropts] (common-support
kernel density plots)

kmatch ccumul [varlist] [, gropts] (common-support
cumulative distribution plots)

kmatch cbox [varlist] [, gropts] (common-support
box plots)

md_options Description

Main
metric(metric) distance metric for covariates

matching_options matching options

general_options estimands, standard errors, reporting, etc.

Propensity score
psvars(varlist) include propensity score estimated from varlist

pscore(varname) include propensity score contained in varname

psweight(#) weight given to the propensity score

comsup[(lb [ub])] restrict common support of
propensity score

pscore_options propensity score estimation options

Entropy balancing
ebalance[(varlist)] apply entropy balancing to the matched sample

csonly only use common support information and ignore matching weights

ebalance_options other entropy balancing options

ps_options Description

Main
comsup[(lb [ub])] restrict common support of
propensity score

pscore(varname) variable providing the propensity score

pscore_options propensity score estimation options

matching_options matching options

general_options estimands, standard errors, reporting, etc.

Entropy balancing
ebalance[(varlist)] apply entropy balancing to the matched sample

csonly only use common support information and ignore matching weights

ebalance_option other entropy balancing options

em_options Description

Main
general_options estimands, standard errors, reporting, etc.

Entropy balancing
ebalance(varlist) apply entropy balancing to the matched sample

csonly only use common support information and ignore matching weights

ebalance_options other entropy balancing options

eb_options Description

Main
ebalance_options entropy balancing options

general_options estimands, standard errors, reporting, etc.

Propensity score
comsup[(lb [ub])] restrict common support based on
propensity score

psvars(varlist) estimate propensity score from varlist

pscore(varname) variable providing the propensity score

pscore_options propensity score estimation options

ipw_options Description

Main
comsup[(lb [ub])] restrict common support of
propensity score

pscore(varname) variable providing the propensity score

pscore_options propensity score estimation options

nonormalize do not normalize the weights

general_options estimands, standard errors, reporting, etc.

Entropy balancing
ebalance[(varlist)] apply entropy balancing to the reweighted sample

csonly only use common support information and ignore the IPWs

ebalance_options other entropy balancing options

ra_options Description

Main
general_options estimands, standard errors, reporting, etc.

Propensity score
comsup[(lb [ub])] restrict common support based on
propensity score

psvars(varlist) estimate propensity score from varlist

pscore(varname) variable providing the propensity score

pscore_options propensity score estimation options

matching_options Description

Main
nn[(#)] use nearest-neighbor matching instead of kernel matching

keepall do not enforce minimum number of nearest neighbors

wor apply nearest-neighbor matching without replacement

ridge use ridge matching instead of kernel matching

kernel(kernel) kernel
function; default is kernel(epan)

ematch(emvars) match exactly on the
specified variables (after optional coarsening)

Bandwidth/Caliper
bwidth(bwspec) half-width of
kernel/caliper for nn-matching

caliper(numlist) synonym for bwidth(numlist)

sharedbwidth use same bandwidth/caliper for both matching directions

bwadjust(numlist) adjust bandwidth/caliper by specified factor

pscore_options Description

pscmd(command) command used to estimate the propensity score;
default is logit

psopts(options) options passed through to the propensity
score estimation command

maxiter(#) set maximum number of iterations for propensity
score estimation; default is # = min(50,c(maxiter))

pspredict(options) options passed through to predict;
default is pspredict(pr)

ebalance_options Description

targets(numlist) specify
target moments to be balanced; default is targets(1) (means)

covariances additionally balance covariances

btolerance(#) balancing tolerance; default is btolerance(1e-5)

fitopts(options) details of the balancing algorithm

general_options Description

Main
tvalue(#) value of tvar that is the treatment; default is
tvalue(1)

over(varname) compute results for subpopulations defined by the
values of varname

Estimands
ate average treatment effect; the default

att average treatment effect on the treated

atc average treatment effect on the untreated

nate naive average treatment effect

po potential outcome averages

SE/CI
vce(vcetype) vcetype may
be analytic (the default), cluster clustvar, bootstrap, or jackknife

svy use survey variance estimation as set by svyset

subpop(subpop) restrict survey estimation to a subpopulation

nose do not compute standard errors

Reporting
level(#) set confidence level; default is level(95)

noisily display auxiliary results

noheader suppress output header

nomtable suppress matching statistics

notable suppress coefficients table (treatment effects)

display_options standard
reporting options

Generate
generate[(spec)] generate variables
containing matching results

wgenerate[(spec)] generate
variables containing ready-to-use matching weights

dygenerate[(spec)] generate variables
containing potential outcome differences

idgenerate[(prefix)] generate variables
containing IDs of the matched controls (matching only)

idvar(varname) provide custom IDs to be used by idgenerate() (matching only)

dxgenerate[(prefix)] generate variables
containing distances to the matched controls (matching only)

cemgenerate[(spec)] generate variables
containing coarsened covariates (matching only)

ifgenerate[(spec)] generate variables
containing the influence functions

replace allow overwriting existing variables

cvplotopts Description

index display index using marker labels

range(lb [ub]) restrict results to bandwidths within [lb, ub]

notreated omit results for treated

nountreated omit results for untreated

scatter_options any options allowed by
graph twoway scatter

combopts(options) options passed
through to graph combine

titles(strlist) titles for subgraphs

sumopts Description

ate | att | atc report results corresponding to
specified estimand

sd report standard deviations instead of variances

skewness additionally report skewnesses

meanonly display table reporting means only

varonly display table reporting variances only

skewonly display table reporting skewnesses only

gropts Description

Common options
ate | att | atc report results corresponding to
specified estimand

overlevels(numlist) report results for selected subpopulations

combopts(options) options passed
through to graph combine

titles(strlist) titles for subgraphs

labels(strlist) (balancing plots only) subgraph labels for raw and
matched samples

byopts(byopts) (balancing plots
only) options passed through to by()

nomatched (common-support plots only) omit results for matched observations

nounmatched (common-support plots only) omit results for unmatched observations

nototal (common-support plots only) omit results for combined sample

All but box/cbox
line_options any options allowed by
graph twoway line

For box/cbox
legend_options options controlling the
legend

boxlook_options graph box
options controlling the look of the boxes

axis_options graph box
options controlling rendering of the y axis

other_options graph box
options controlling titles, added text, aspect ratio, etc.

For density/cdensity
n(#) estimate density using # points; default is n(512)

bwidth(#|type) set bandwidth to # or
specify automatic bandwidth selector

adjust(#) scale bandwidth by #

adaptive[(#)] use the adaptive
kernel density estimator

ll(#) value of lower boundary of the domain of the variable

ul(#) value of upper boundary of the domain of the variable

reflection | lc select the boundary correction technique;
default is renormalization

kernel(kernel) type of kernel function

Description

kmatch matches or balances treated and untreated observations with
respect to covariates and, if outcome variables are provided, estimates
treatment effects based on the matched/balanced observations, possibly
including post-matching regression adjustment. Several matching or balancing
commands are available:

kmatch md applies multivariate-distance matching (Mahalanobis
matching by default). A kernel function will be used to
determine and weight the matches (see, e.g., Heckman et al. 1998a, 1998b).
Alternatively, if the nn() option is specified,
nearest-neighbor matching will be applied. For kernel matching, several
methods for data-driven bandwidth selection are offered; see the
bwidth() option. If covariates (avars)
are specified for the outcome variables, treatment effects estimation will
include regression adjustment (equivalent to the bias-correction proposed
by Abadie and Imbens 2011).

kmatch ps applies propensity-score matching, using kernel matching or
nearest-neighbor matching and possibly including regression adjustment
as described for kmatch md.

kmatch em applies exact matching or coarsened exact matching
(Iacus et al. 2012). See below for information on how to specify
coarsening rules for the covariates. Exact matching is
also available with kmatch md and kmatch ps through the
ematch() option.

kmatch eb applies entropy balancing (Hainmueller 2012). Entropy balancing
is also available as a refinement in kmatch md, kmatch ps, kmatch em,
and kmatch ipw through the ebalance() option.

kmatch ipw applies inverse probability weighting (IPW).

kmatch ra applies regression adjustment. Regression adjustment is
also supported by all of the above commands. Use kmatch ra only if
you want to compute raw regression-adjustment estimates without matching or
reweighting.

After running one of the above commands, several post-estimation commands
are available. A first set of commands can be used to evaluate the
balancing of the data:

kmatch summarize reports means and variances (and, optionally,
skewnesses) of the covariates for the treated and the untreated before
and after matching.

kmatch density displays kernel density estimates of the specified
variable(s) before and after matching. For kmatch ps and
kmatch ipw, the density of the propensity score is displayed by
default.

kmatch cumul is like kmatch density, but displays cumulative
distributions.

kmatch box is like kmatch density, but displays box plots.

A second set of post-estimation commands can be used to evaluate how the
common support deviates from the overall sample. If some of the
observations have been excluded from the matching solution due to lack of
common support, generalizability of the obtained results may be
compromised. The following commands are helpful to compare matched and
unmatched observations in such a situation:

kmatch csummarize reports means and variances (and, optionally,
skewnesses) of the covariates in the matched sample, the unmatched sample,
and the overall sample.

kmatch cdensity displays kernel density estimates of the specified
variable(s) in the matched sample, the unmatched sample,
and the overall sample. For kmatch ps and
kmatch ipw, the density of the propensity score is displayed by
default.

kmatch ccumul is like kmatch cdensity, but displays cumulative
distributions.

kmatch cbox is like kmatch cdensity, but displays box plots.

Finally, post-estimation command kmatch cvplot can be used
to display the trace of the search algorithm after kmatch md or
kmatch ps if cross-validation has been employed for
bandwidth selection.

kmatch requires moremata
to be installed on the system. See
ssc describe moremata.

Options for kmatch md

Main

metric(metric) specifies the scaling matrix used to compute the
multivariate distances. Option metric() is only allowed for
kmatch md. metric may be:

mahalanobis [units] [, weights(numlist) ]

ivariance [units] [, weights(numlist) ]

euclidean

matrix matname

mahalanobis sets the scaling matrix to the sample covariate
covariance matrix (separately for each over group). If units is
provided, the matrix is transformed in a way such that its diagonal
elements are equal to the squares of the specified values (while preserving
the correlation structure). That is, if V is the sample covariance matrix
and sd is the vector of sample standard deviations, the scaling matrix
is defined as S = diag(units:/sd) * V *
diag(units:/sd). The rational behind such a transformation is a
follows. The Mahalanobis distance can be interpreted as measuring the
distance between observations in terms of standard deviations of the
covariates (while additionally taking into account the correlation
structure). Instead of using standard deviations as relevant units, you may
want to specify your own units. units must contain one value for each
covariate (plus an additional value for the propensity score, if option
psvars() or option pscore() has been specified). If option
weights() is specified, the scaling matrix is defined as S =
diag(1:/w) * V * diag(1:/w), where w is the vector of the specified
weights (this is equivalent to reweighing as suggested by Greevy et al.
2012). w must contain as many values as there are covariates. The
default is to give each covariate a weight of one. If psvars() or
pscore() has been specified, you can use option psweight() to
assign a weight to the propensity score. If psweight() is omitted,
the propensity score receives a weight of one. If both, units and
weights, are provided, both transformations are applied.

ivariance sets the scaling matrix to a diagonal matrix with the
sample covariate variances on the diagonal (separately for each over
group). Argument units and option weights() are as above.

euclidean sets the scaling matrix to the identity matrix.

matrix uses the provided matrix as scaling matrix.

matching_options select the type of matching
procedure and set the details of the matching algorithm and
bandwidth selection.

general_options select the estimands to be
computed and set the details about standard errors, reporting, and results to
be returned.

Propensity score

psvars(varlist) specifies that the propensity score estimated from
varlist is to be included as an additional variable
in the computation of the distances. varlist
may contain factor variables. Only one of psvars() and
pscore() is allowed.

pscore(varname) specifies that the propensity score contained in
varname is to be included as an additional variable
in the computation of the distances. Only one of psvars() and
pscore() is allowed.

psweight(#) specifies the weight given to the propensity score when
computing distances; see the metric() option above. The
default is psweight(1).

comsup[(lb [ub])] restricts the range of observations
that are treated as potential matches. If comsup is specified without
argument, observations outside the common range of the propensity score
will not be matched. The common range is defined as the range between
max(min(ps|treatment), min(ps|control)) and
min(max(ps|treatment), max(ps|control)), where ps
is the propensity score. Alternatively, observations with a propensity
score smaller than lb or, if ub is also specified, a propensity
score larger than ub will be excluded. comsup() only has an
effect if psvars() or pscore() is specified.

pscore_options set the details
of the propensity score estimation.

Entropy balancing

ebalance[(varlist)] refines the matching weights by applying
entropy balancing after running the matching procedure. The variables specified
in varlist will be included in the entropy balancing procedure. varlist
may contain factor variables. If
varlist is omitted, the default is to include the main covariates (xvars).

csonly causes entropy balancing to be based on common
support information only, ignoring the matching weights. By default, entropy
balancing will use the matching weights as base weights and refine
these weights until balance is achieved within the sample of matched
observations. If csonly is specified, entropy balancing will balance
the sample of matched observations starting from scratch, that is, ignoring the
matching weights.

ebalance_options select the target moments to be
balanced and set the details of the entropy balancing algorithm.

Options for kmatch ps

Main

comsup[(lb [ub])] restricts the range of observations
that are treated as potential matches. If comsup is specified without
argument, observations outside the common range of the propensity score
will not be matched. The common range is defined as the range between
max(min(ps|treatment), min(ps|control)) and
min(max(ps|treatment), max(ps|control)), where ps
is the propensity score. Alternatively, observations with a propensity
score smaller than lb or, if ub is also specified, a propensity
score larger than ub will be excluded.

pscore(varname) provides a variable containing the propensity score.
No propensity score model will be estimated in this case.

pscore_options set the details
of the propensity score estimation.

matching_options select the type of matching
procedure and set the details of the matching algorithm and
bandwidth selection.

general_options select the estimands to be
computed and set the details about standard errors, reporting, and results to
be returned.

Entropy balancing

ebalance[(varlist)] refines the matching weights by applying
entropy balancing after running the matching procedure. The variables specified
in varlist will be included in the entropy balancing procedure. varlist
may contain factor variables. If
varlist is omitted, the default is to include the main covariates (xvars).

csonly causes entropy balancing to be based on common
support information only, ignoring the matching weights. By default, entropy
balancing will use the matching weights as base weights and refine
these weights until balance is achieved within the sample of matched
observations. If csonly is specified, entropy balancing will balance
the sample of matched observations starting from scratch, that is, ignoring the
matching weights.

ebalance_options select the target moments to be
balanced and set the details of the entropy balancing algorithm.

Options for kmatch em

Main

general_options select the estimands to be
computed and set the details about standard errors, reporting, and results to
be returned.

Entropy balancing

ebalance[(varlist)] refines the matching weights by applying
entropy balancing after running the matching procedure. The variables specified
in varlist will be included in the entropy balancing procedure. varlist
may contain factor variables.

csonly causes entropy balancing to be based on common
support information only, ignoring the matching weights. By default, entropy
balancing will use the matching weights as base weights and refine
these weights until balance is achieved within the sample of matched
observations. If csonly is specified, entropy balancing will balance
the sample of matched observations starting from scratch, that is, ignoring the
matching weights.

ebalance_options select the target moments to be
balanced and set the details of the entropy balancing algorithm.

Options for kmatch eb

Main

ebalance_options select the target moments to be
balanced and set the details of the entropy balancing algorithm.

general_options select the estimands to be
computed and set the details about standard errors, reporting, and results to
be returned.

Propensity score

comsup[(lb [ub])] restricts the range of observations
that are included in the entropy balancing. If comsup is specified without
argument, observations outside the common range of the propensity score
will not be included. The common range is defined as the range between
max(min(ps|treatment), min(ps|control)) and
min(max(ps|treatment), max(ps|control)), where ps
is the propensity score. Alternatively, observations with a propensity
score smaller than lb or, if ub is also specified, a propensity
score larger than ub will be excluded.

psvars(varlist) specifies the variables to be used for propensity
score estimation. varlist may contain factor variables. The
default is to use the main covariates (xvars). psvars()
only has an effect if comsup() is specified. Only one of psvars() and
pscore() is allowed.

pscore(varname) provides a variable containing the propensity
score. No propensity score model will be estimated in this case. pscore()
only has an effect if comsup() is specified. Only one of psvars() and
pscore() is allowed.

pscore_options set the details
of the propensity score estimation.

Options for kmatch ipw

Main

comsup[(lb [ub])] restricts the range of observations
that are included in the inverse probability weighting. If comsup is specified without
argument, observations outside the common range of the propensity score
will not be included. The common range is defined as the range between
max(min(ps|treatment), min(ps|control)) and
min(max(ps|treatment), max(ps|control)), where ps
is the propensity score. Alternatively, observations with a propensity
score smaller than lb or, if ub is also specified, a propensity
score larger than ub will be excluded.

pscore(varname) provides a variable containing the propensity score.
No propensity score model will be estimated in this case.

pscore_options set the details
of the propensity score estimation.

nonormalize omits the normalization of the weights computed from the
propensity score. The default is to rescale the weights such that their sum
equals the size of the matched group. If nonormalize is specified the
equality only holds approximately.

general_options select the estimands to be
computed and set the details about standard errors, reporting, and results to
be returned.

Entropy balancing

ebalance[(varlist)] refines the weights by applying
entropy balancing after running the IPW procedure. The variables specified
in varlist will be included in the entropy balancing procedure. varlist
may contain factor variables. If
varlist is omitted, the default is to include the main covariates (xvars).

csonly causes entropy balancing to be based on common
support information only, ignoring the IPWs. By default, entropy
balancing will use the IPWs as base weights and refine
these weights until balance is achieved within the common-support sample. If
csonly is specified, entropy balancing will balance
the common-support sample starting from scratch, that is, ignoring the
IPWs.

ebalance_options select the target moments to be
balanced and set the details of the entropy balancing algorithm.

Options for kmatch ra

Main

general_options select the estimands to be
computed and set the details about standard errors, reporting, and results to
be returned.

Propensity score

comsup[(lb [ub])] restricts the range of observations
that are included in the regression adjustment. If comsup is specified without
argument, observations outside the common range of the propensity score
will not be included. The common range is defined as the range between
max(min(ps|treatment), min(ps|control)) and
min(max(ps|treatment), max(ps|control)), where ps
is the propensity score. Alternatively, observations with a propensity
score smaller than lb or, if ub is also specified, a propensity
score larger than ub will be excluded. comsup() only has an effect
if psvars() or pscore() is specified.

psvars(varlist) specifies the variables to be used for propensity
score estimation. varlist may contain factor variables. psvars()
only has an effect if comsup() is specified. Only one of psvars() and
pscore() is allowed.

pscore(varname) provides a variable containing the propensity
score. No propensity score model will be estimated in this case. pscore()
only has an effect if comsup() is specified. Only one of psvars() and
pscore() is allowed.

pscore_options set the details
of the propensity score estimation.

Matching options

Main

nn[(#)] requests that nearest-neighbor matching
(with replacement) is used instead of kernel matching or ridge matching,
where # specifies the (minimum) number of matches per observation. The
default is nn(1) (one-to-one matching with replacement).

keepall causes observations to be treated as matched even if the
minimum number of nearest neighbors is not reached. The default, unless
wor is specified, is to treat such observations as unmatched. keepall
is only relevant if nn()>1 is specified.

wor applies nearest-neighbor matching without replacement. wor is
only allowed if nn() is specified. A greedy matching algorithm is
used that assigns matches in ascending order of the distances between the
observations (where "distance" is either the multivariate distance or the
absolute difference in propensity score); see
mm_greedy(). Ties will be processed in random order; for
stable results set the sort seed (see set sortseed). The algorithm
is computationally intensive and will be slow in large datasets. Speed can
usually be increased substantially by matching some of the covariates
exactly using the ematch() option. wor implies keepall.
fweights are not supported by wor.

ridge[(#)] requests that ridge matching is used
instead of standard kernel matching, where # is the ridge parameter
(see Frölich 2004, 2005). Specifying # is not necessary
as kmatch picks a parameter appropriate for the chosen kernel. However,
you can type ridge(0) if you want to apply standard local-linear
matching.

kernel(kernel) specifies the kernel
function for kernel matching and ridge matching. kernel may be:

epan Epanechnikov kernel function; the default
rectangle rectangle kernel function
uniform synonym for rectangle
triangle triangle kernel function
biweight biweight kernel function
triweight triweight kernel function
cosine cosine trace kernel function
parzen Parzen kernel function

All kernels are defined such that they have a support of +/- 1.

ematch(emvars) requests that the specified variables are matched
exactly. Factor variables are not allowed in emvars, but you may
include coarsening rules to transform the variables before matching (as
proposed by Blackwell et al. 2009, Iacus et al. 2012). The
syntax of emvars is

[(rule)] varlist [ (rule) varlist ... ]

where rule will be applied to each variable of the subsequent
varlist up to the next rule specification. Omitting the initial rule
is equivalent to setting the rule to asis. rule may be:

asis do not coarsen; synonyms for (asis) are (#0), (.), and ()

numlist coarsen at specified cutpoints

#c coarsen at c equally spaced cutpoints

hist use cutpoints based on the rule used by histogram

sturges use cutpoints based on Sturges' formula

rice use cutpoints based on the Rice Rule

doane use cutpoints based on Doane's formula

scott use cutpoints based on Scott's normal reference rule

fd use cutpoints based on Freedman–Diaconis' choice

The named rules above are methods for determining the number of bins or the bin
width in a histogram; for hist see help histogram; for the
other rules see http://en.wikipedia.org/wiki/Histogram. Let
c be the number of cutpoints and h be the bin
width. kmatch sets the cutpoints such that the range of x is divided
into c+1 equally spaced bins. For methods that determine h,
c is computed as ceil(range(x)/h); the resulting bin width may thus
be different from the initial h. Furthermore, c is restricted to
a minimum of one (at least two bins).

Bandwidth/Caliper

bwidth(bwspec) specifies the half-width of the kernel for kernel and
ridge matching or sets a caliper for nearest-neighbor matching. If the
distance between two observations is larger (or, for kernel and ridge
matching, larger-or-equal) than the specified bandwidth or caliper they are
not considered as a (potential) match. For nearest-neighbor matching, the
default is to allow all observations as potential matches regardless of
distance. For kernel and ridge matching the default is to select a
bandwidth based on the pair-matching algorithm described below. bwspec
may be

numlist

to provide a specific bandwidth or caliper. If multiple values are specified,
different bandwidths are used for the different matching directions and over
groups (each over group consumes one or two values depending on whether
one-sided or two-sided matching has been requested and depending
on whether sharedbwidth has been specified; values will be recycled
if numlist contains fewer values than matching directions
times over groups). For kernel and ridge matching, bwspec may also be

pm [q [f]] [, quietly]

to select a bandwidth based on a pair-matching algorithm similar to the proposal by
Huber et al. (2013, 2015). The algorithm sets the bandwidth to f times
the q-quantile of the distribution of (non-zero) distances between
observations in one-to-one matching (1-nearest-neighbor matching
with replacement). Factor f defaults to 1.5, quantile q defaults
to 0.90. Option quietly suppresses the output of the algorithm.
Alternatively, for kernel and ridge matching, bwspec may be

cv [cvvar] [,
weighted
nopenalty
nolimit
quantile(#)
factor(#)
sfactor(#)
n(#)
range(lb ub)
grid(numlist)
exact
quietly ]

to determine the bandwidth by cross-validation. If outcome variable
cvvar is provided, cross-validation with respect to cvvar as
suggested by Frölich (2004, 2005) is performed. If, in addition, option
weighted is specified, weighted cross-validation with respect to
cvvar as suggested by Galdo et al. (2008; Section 4.2) is
performed. Deviating from the literature, a correction is applied for loss of
observations if there is lack of common support. Specify option
nopenalty to skip the correction. If cvvar is omitted,
cross-validation is performed with respect to the mean of the propensity
score (in case of kmatch ps) or the means of the covariates (in case
of kmatch md). Option nopenalty has no effect in this
case. Occasionally, cross-validation can yield excessively large bandwidth
estimates. To limit such behavior, a penalty is applied to the cross-validation
criterion for bandwidths larger than the standard deviation of the
propensity score (in case of kmatch ps) or the square-root of the number
of covariates (in case of kmatch ps). Specify option nolimit
to omit the penalty.

By default, the cross-validation search algorithm starts at the bandwidth
determined by the pair-matching method described above and leaps up or down
until a local minimum is encountered. The local minimum is then further
refined until the maximum number of steps is reached. Options
quantile() and factor() set the parameters for the initial
pair-matching bandwidth (see above). Option sfactor() sets the
relative step size for the first phase of the search algorithm. The default
is 1.5, meaning that the bandwidth is either multiplied by 1.5 or divided by
1.5 from one step to the next, depending on search direction. The default
is to start the algorithm with a step up; set sfactor()
to a value between 0 and 1 to start with a step down. Option n()
sets the total number of steps; default is 15. Alternatively, specify
range() to use an equally-spaced evaluation
grid between lb and ub, or provide a custom evaluation grid using
the grid() option. For ridge matching, cross-validation without
cvvar is only approximate for reasons of speed; specify option
exact to request exact computations (exact has no effect
if cvvar is provided). Furthermore, specify option
quietly to suppress the output of the algorithm.

caliper(numlist) is a synonym for bwidth(numlist).

sharedbwidth requests that the same bandwidth is used for both matching
directions. By default, bandwidth search will be run separately for the treated
and for the untreated. If sharedbwidth is specified, bandwidth search will
be run jointly across both groups. Option sharedbwidth has no effect
if only one matching direction has been requested.

bwadjust(numlist) adjusts the bandwidth or caliper by multiplying it by the
specified factor. If multiple values are specified, different adjustments
are used for the different matching directions and over groups (each over
group consumes one or two values depending on whether one-sided or
two-sided matching has been requested; values will be recycled if
numlist contains fewer values than matching directions times
over groups).

Propensity score estimation options

pscmd(command) specifies the command used to estimate the propensity
score. The the default command is logit. For example, specify
pscmd(probit) to use a probit model.

psopts(options) provides options to be passed through to the
propensity score estimation command.

maxiter(#) sets the maximum number of iterations for the propensity
score estimation command, where # can be between 0 and 16000. The default is
# = min(50,c(maxiter)) (standard commands such as logit or probit
typically converge within just a handful of iterations if a solution exists).
maxiter() temporarily resets set maxiter; commands
that are not sensitive to this setting will not be affected.

pspredict(options) provides options to be passed through to the call
to predict that generates the propensity scores after model
estimation. The default is pspredict(pr) so that probabilities are
generated. For example, specify pspredict(xb) to use the liner
predictor instead of probabilities. Options allowed in pspredict()
depend on the command used for model estimation; see pscmd() above.

Entropy balancing options

targets(numlist) specifies the target moments to be balanced. numlist may contain
values 1 (balance mean), 2 (balance mean and variance), and
3 (balance mean, variance, and skewness). The elements of numlist will
be applied to the covariates one after the other. If numlist is shorter
then the number of covariates, the element will be recycled. For example,
targets(2) will balance all means and all variances; targets(1 2) will balance
the mean of the first (and 3rd, 5th, etc.) variable and the mean and variance of the
second (and 4th, 6th, etc.) variable. Higher order moments that
are collinear with lower order moments will be omitted automatically. The default is
targets(1) (balance all means).

covariances additionally balances all covariances between the covariates.

btolerance(#), #>0, sets the balancing tolerance. Balancing is achieved if the
balancing loss is smaller than btolerance(). Treatment effects estimates
based on solutions that do not achieve balance are set to 0 and flagged as
omitted.

fitopts(options) set the details of the balancing algorithm. options
are as follows:

dfcorrection applies degrees-of-freedom correction to balancing
constraints for variances and covariances. The default balancing
constraints are consistent with computing variances and covariances in the
reweighted group based on weights that are normalized to sum to the size of
the target group (or with variance formulas that ignore degrees-of-freedom
adjustment in the denominator). If dfcorrection is specified, the
results are consistent with weights normalized to the size of the
reweighted group (which is equivalent to how summarize with
aweights computes variances). dfcorrection only affects
variances and covariances that are not collinear with lower moments.

nconstraint includes the normalization constraint (target sum of weights)
in the optimization problem, rather than rescaling the weights ex
ante. In this case, if perfect balance is not possible, the sum of the
balancing weights is no longer guaranteed to be equal to the size of the
target group.

nostandardize suppresses standardization of the constraint matrix. By
default, the columns of the constraint matrix are divided by the
standard deviations of the corresponding terms in the target group (if the
standard deviations exist). This should make the optimization more stable
as all constraints have a similar scaling and the balancing loss is
expressed in terms of standardized differences.

difficult causes an alternative stepping algorithm to be used in
nonconcave regions of the optimization problem. See the difficult option
in maximize for more information.

maxiter(#), # in [0,16000], sets the maximum
number of iterations. The default is c(maxiter) as set by
set maxiter.

ptolerance(#) and vtolerance(#) set the convergence tolerances
for the parameter vector (lambda coefficients) and the balancing loss,
respectively. The defaults are ptolerance(1e-6) and
vtolerance(1e-7). Convergence is reached if the maximum relative change in
the parameter vector is smaller than ptolerance() or if the
relative change in the balancing loss is smaller than vtolerance().

General options (estimands, standard errors, reporting, etc.)

Main

tvalue(#) specifies the value of tvar that is the treatment. The
default is tvalue(1).

over(varname) computes results for each subpopulation defined
by the values of varname. Matching is performed separately for each
group.

Estimands

ate requests that average treatment effects are reported. This is
the default unless att and/or atc is specified. If you want to
report results for multiple estimands, type several of these options. The options also
affect whether two-sided or only one-sided matching is performed. ate
requires matching in both directions; att requires matching
the treated; atc requires matching the untreated.

att requests that average treatment effects on the
treated are reported.

atc requests that average treatment effects on the
untreated are reported.

nate requests that naive average treatment effects
(unconditional mean differences; without regression adjustment) are reported
in addition to the matched treatment effects.

po requests that potential outcome averages are reported in addition
to the treatment effects.

SE/CI

vce(vcetype) determines how standard errors and confidence intervals
are computed. vcetype may be:

analytic
cluster clustvar
bootstrap [, bootstrap_options]
jackknife [, jackknife_options]

The default is analytic. If vce() is analytic or
cluster, the standard errors are estimated based on influence functions
(see Jann 2019),
assuming the matching or balancing weights to be fixed. Assuming the weights
to be fixed is an oversimplification that may bias the results. My experience
from some limited simulations is that the influence-function
standard errors will tend to be conservative (i.e. to large; except for
kmatch ra, for which the influence-function standard errors are
consistent). However, applying post-matching regression adjustment seems to
help a lot, at least in my simulations. Not only did regression adjustment
reduce the bias in the treatment effect estimates (due to exploitation of the
double-robust property), it also made the influence-function standard
errors consistent in most cases.

To get better standard errors I suggest to rely on teffects
whenever possible and use vce(bootstrap) in other cases. In my
simulations, the bootstrap generally produced good results, with the
exception of nearest-neighbor matching, where the bootstrap standard errors
tended to be conservative. For nearest-neighbor matching it has also been
shown theoretically that the boostrap is not consistent (Abadie and Imbens
2008). Official Stata's teffetcs nnmatch and
teffetcs psmatch will produce consistent standard errors for nearest-neighbor
matching.

In case of kernel and Ridge matching with automatic bandwidth selection,
the bandwidth is held fixed across bootstrap or jackknife
replications. If you want to repeat bandwidth search in each
replication, use the bootstrap or jackknife prefix
command.

In small samples it may happen that some estimates cannot be
computed in a specific replication (for example, because the treatment
does not vary). kmatch returns such estimates as 0 and sets
e(k_omit) to the number of estimates that could not be
computed. To prevent bootstrap and jackknife
from using these estimates, add option reject(e(k_omit)) to the
bootstrap or jackknife command. That is, for example, type

bootstrap, reject(e(k_omit)): kmatch ...

When using bootstrap or jackknife via the vce() option,
such estimates are excluded automatically.

vce(bootstrap) and vce(jackknife) require that at least one
outcome variable has been specified.

svy causes the survey design to be taken into account for variance
estimation, using the estimation method as set in svyset. This option may
not be specified with vce() or weights, and it requires that at least one
outcome variable has been specified. Taylor-linearized variance estimation will
be based on influence functions assuming balancing weights as fixed; see the
vce() option.

subpop(subpop) restricts survey estimation to a single
subpopulation identified by subpop, which is

[varname] [if]

The subpopulation is defined by observations for which varname!=0 and
for which the if condition is met. See help svy and
[SVY] subpopulation estimation for more information on subpopulation
estimation. subpop() requires the svy option.

nose suppresses the computation of standard errors. Use this option
if you want to save computer time, for example, in simulations. nose may not be
specified with vce() or svy.

Reporting

level(#) specifies the confidence level, as a percentage, for
confidence intervals. The default is level(95) or as set by
set level.

noisily displays auxiliary results such as the output from propensity
score estimation or the output from regression adjustment.

noheader suppresses the output header.

nomtable suppress the table containing the matching statistics.

notable suppresses the coefficients table containing the
treatment effects.

display_options are standard reporting options as described in
[R] estimation options.

Generate

generate[(spec)] generates a number of variables
containing the matching results. spec may either be
newvarlist to provide explicit names for the generated
variables or prefix* to provide a prefix for the variable names.
The default prefix is _KM_. The following variables will be generated:

_KM_treat treatment indicator

_KM_nc number of matched controls

_KM_nm number of times used as a match

_KM_mw matching weight

_KM_ps propensity score (only if a propensity has been estimated)

_KM_strata matching stratum (kmatch md, kmatch ps, and kmatch em only)

wgenerate[(spec)] generates variables
containing the ready-to-use matching weights. spec may either be
newvarlist to provide explicit names for the
generated variables or prefix* to provide a prefix for the
variable names. The default prefix is _W_. A selection of the
following variables will be generated:

_W_ATE weights for computing the ATE (if ate or none of ate, att, and atc is specified)

_W_ATT weights for computing the ATT (if att is specified)

_W_ATC weights for computing the ATC (if atc is specified)

Variable _KM_mw stored by generate() contains raw control observation
matching weights that need to be modified if you want
to use them to estimate a treatment effect. In contrast, wgenerate()
stores weights to which the necessary modifications have been applied. The
definitions are

_W_ATE = w + _KM_mw * fw
_W_ATT = cond(_KM_treat==1, w, _KM_mw * fw)
_W_ATC = cond(_KM_treat==0, w, _KM_mw * fw)

where w are the base weights (or 1 if no weights have been specified)
and fw = w in case of fweights and 1 else. In addition, the
stored weights take into account whether an observation could be matched or was used
as a match (the weights will be zero for observations that could neither be matched
nor were used as a match). The weights stored by wgenerate() can be used
as is in commands such as regress or teffects ra to reproduce
the estimates reported by kmatch (although standard errors will not be
exactly the same). Here is an example:

. sysuse nlsw88, clear

. kmatch md union age married grade south smsa (wage), att wgenerate(W)

. regress wage union [pweight = W]

. kmatch md union age married grade south smsa (wage = age married grade south smsa), att wgenerate(W) replace

. teffects ra (wage age married grade south smsa) (union) [pweight = W], atet

dygenerate[(spec)] generates variables containing potential
outcome differences. spec may either be
newvarlist to provide explicit names for the generated
variables or prefix* to provide a prefix for the variable names.
The variables will then be named as prefixovar, where ovar
is the name of the outcome variable. The default prefix is _DY_. If
regression adjustment is applied, potential outcomes will be computed as
predictions from the regression adjustment equation plus the residuals from
a regression of the unadjusted potential outcomes on the adjustment
variables.

idgenerate[(prefix)] generates variables containing
the IDs (observations numbers) of the matched controls. The variables will
be named as prefix#, where # is an index for the number of the
control. The default prefix is _ID_. idgenerate() is only
allowed with kmatch md, kmatch ps, and kmatch em.

idvar(varname) provides custom IDs to be used by idgenerate().
varname may be numeric or string. The default is to use the
observation numbers as IDs (based on the sort order at the time when
kmatch is called). idvar() is only
allowed with kmatch md, kmatch ps, and kmatch em.

dxgenerate[(prefix)] generates variables containing
the individual distances to the matched controls (Mahalanobis distances or propensity
score differences, depending on context). The variables will be named as
prefix#, where # is an index for the number of the control. The
default prefix is _DX_. dxgenerate() is only
allowed with kmatch md, kmatch ps, and kmatch em.

cemgenerate[(spec)] stores the coarsened variables
resulting from emvars. spec may either be
newvarlist to provide explicit names for the
generated variables or prefix* to provide a prefix for the
variable names. Unless newvarlist is specified, the generated
variables will be named as prefixvarname, where varname
is the name of the coarsened variable. cemgenerate() is only
allowed with kmatch md, kmatch ps, and kmatch em.

ifgenerate[(spec)] generates variables
containing the influence functions that were used to estimate the
standard errors. ifgenerate() only has an effect if vce()
is analytic or cluster. spec may either be
newvarlist to provide explicit names for the generated
variables or prefix* to provide a prefix for the variable names. The
default prefix is _IF_.

replace allows generate(), dygenerate(),
idgenerate(), dxgenerate(), and ifgenerate() to overwrite
existing variables.

Options for kmatch cvplot

index displays index numbers for the steps of the search algorithm
as marker labels. Use marker_label_options to change the position
and style of the marker labels.

range(lb ub) restricts the displayed results to bandwidths within the
specified range.

notreated omits the results of the bandwidth search for matching the
treated and nountreated omits the results of the bandwidth search for
matching the untreated. These options only have an effect if separate results
for the treated and the untreated are available. Only one of
notreated and nountreated is allowed.

scatter_options are any options allowed by
graph twoway scatter.

combopts(options) are options passed
through to graph combine. This is only relevant when plotting results from
multiple over-groups.

titles(strlist) provides titles for the subgraphs. This is only
relevant when plotting results from multiple over-groups. Enclose the
titles in double quotes if they contain spaces, e.g.,
titels("Title 1" "Title 2" ...).

Options for kmatch summarize and kmatch csummarize

ate, att, and atc select the results to be reported. Only
one of ate, att, and atc is allowed. ate reports
results corresponding to the ATE; att reports results corresponding
to the ATT; atc reports results corresponding to the ATC. Whether a
specific option is allowed depends context.

sd reports standard deviations instead of variances.

skewness requests that skewnesses be computed in addition to means and variances.

meanonly displays only the table reporting means.

varonly displays only the table reporting variances or standard deviations.

skewonly displays only the table reporting skewnesses.

Options for balancing plots and common-support plots

Common options

ate, att, and atc select the results to be reported. Only
one of ate, att, and atc is allowed. ate reports
results corresponding to the ATE; att reports results corresponding
to the ATT; atc reports results corresponding to the ATC. Whether a
specific option is allowed depends context.

overlevels(numlist) specifies the values of the over-groups
to be included in the graph. The default is to include all over-groups.

combopts(options) are options passed
through to graph combine. This is only relevant when plotting results from
multiple over-groups.

titles(strlist) provides titles for the subgraphs. This is only
relevant when plotting results from multiple over-groups. Enclose the
titles in double quotes if they contain spaces, e.g.,
titels("Title 1" "Title 2" ...).

labels(strlist) specifies labels for the subgraphs by raw and
matched samples. The default is labels("Raw" "Matched"). Option
labels() is only allowed for balancing plots.

byopts(byopts)
are options controlling how the subgraphs by raw and matched samples
are combined. Option byopts() is only allowed for balancing plots.

nomatched omits the results for matched observations. Option
nomatched is only allowed for common-support plots.

nounmatched omits the results for unmatched observations. Option
nounmatched is only allowed for common-support plots.

nototal omits the results for the combined sample. Option
nototal is only allowed for common-support plots.

For all but kmatch box and kmatch cbox

line_options are any options allowed by
graph twoway line

For kmatch box and kmatch cbox

legend_options are options controlling the
legend.

boxlook_options are graph box
options controlling the look of the boxes.

axis_options are graph box
options controlling the rendering of the y axis.

other_options are graph box
options controlling titles, added text, aspect ratio, etc.

For kmatch density and kmatch cdensity

n(#) specifies the number of evaluation points used to estimate the
density. The default is n(512).

bwidth(#|type) sets the bandwidth to # or
specifies the automatic bandwidth selector,
where type is silverman (the default),
normalscale, oversmoothed, sjpi,
dpi[(#)], or isj. See
mm_density() for details.

adjust(#) causes the bandwidth to be multiplied by
#. Default is adjust(1).

adaptive[(#)] causes the adaptive kernel density
estimator to be used. See
mm_density() for details.

ll(#) and ul(#) specify the lower and upper boundary of the
domain of the plotted variable. ll() must be lower than or equal to
the minimum observed value; ul() must be larger than or equal to the
maximum observed value. If plotting the propensity score, ll() and
ul() will be set to 0 and 1.

reflection and lc (linear correction) select the boundary
correction technique to be used for variables with bounded support. The default
technique is renormalization. See
mm_density() for details.

kernel(kernel) specifies the kernel function. Default is kernel(epan2). See
mm_density() for available kernels.

Examples

Multivariate-distance matching
Propensity-score matching
Coarsened exact matching
Entropy balancing
Inverse probability weighting
Regression adjustment

Multiple outcome variables
ATE, ATT, ATC, NATE, and potential outcome means
Results by subpopulations
Balancing diagnostics
Common support diagnostics
Bandwidth selection

Load example data

. webuse cattaneo2, clear

Multivariate-distance matching

Average treatment effect on the treated of mbsmoke on bweight using
Mahalanobis-distance kernel matching

. kmatch md mbsmoke mage prenatal1 mmarried fbaby (bweight), att

Refit the above model, but require exact matches on the binary variables

. kmatch md mbsmoke mage (bweight), ematch(prenatal1 mmarried fbaby) att

Match on two continuous variables, mage and fage, and apply post-matching
regression adjustment

. kmatch md mbsmoke mage fage (bweight = mage fage), ematch(prenatal1 mmarried fbaby) att

Use nearest-neighbor matching (5 neighbors; with replacement) instead of kernel matching

. kmatch md mbsmoke mage fage (bweight = mage fage), ematch(prenatal1 mmarried fbaby) att nn(5)

Compare results to teffects nnmatch

. teffects nnmatch (bweight mage fage) (mbsmoke), ematch(prenatal1 mmarried fbaby) biasadj(mage fage) atet nn(5)

Use nearest-neighbor matching without replacement (1 neighbor)

. kmatch md mbsmoke mage fage (bweight = mage fage), ematch(prenatal1 mmarried fbaby) att nn(1) wor

Use kernel matching including a doubly-weighted propensity score in the Mahalanobis distances

. kmatch md mbsmoke mage prenatal1 mmarried fbaby (bweight), att psvars(fage fedu) psweight(2)

Propensity-score matching

Average treatment effect on the treated of mbsmoke on bweight using kernel matching
based on a logistic model (the default) to predict
each subject's propensity score

. kmatch ps mbsmoke mage fage prenatal1 mmarried fbaby (bweight), att

Refit the above model, but require exact matches on the binary variables

. kmatch ps mbsmoke mage fage (bweight), ematch(prenatal1 mmarried fbaby) att

Include post-matching regression adjustment for the continuous covariates

. kmatch ps mbsmoke mage fage (bweight = mage fage), ematch(prenatal1 mmarried fbaby) att

Use nearest-neighbor matching (5 neighbors; with replacement) instead of kernel matching

. kmatch ps mbsmoke mage fage prenatal1 mmarried fbaby (bweight), att nn(5)

Compare results to teffects nnmatch

. teffects psmatch (bweight) (mbsmoke mage fage prenatal1 mmarried fbaby), atet nn(5)

Use nearest-neighbor matching, but only consider a pair of observations a
match if the absolute difference in the propensity score is less than 0.005
(half a percentage point)

. kmatch ps mbsmoke mage fage prenatal1 mmarried fbaby (bweight), att nn(5) caliper(0.005)

Use ridge matching

. kmatch ps mbsmoke mage fage prenatal1 mmarried fbaby (bweight), att ridge

Use local-linear matching (set the ridge parameter to 0)

. kmatch ps mbsmoke mage fage prenatal1 mmarried fbaby (bweight), att ridge(0)

Coarsened exact matching

Coarsen the continuous covariates using Sturges' formula

. kmatch em mbsmoke (sturges) mage fage (asis) prenatal1 mmarried fbaby (bweight), att

The used cutpoints are stored in e(C_varname)

. matrix list e(C_mage)

. matrix list e(C_fage)

Coarsen the continuous covariates using 9 equally-spaced
cutpoints

. kmatch em mbsmoke (#9) mage fage (asis) prenatal1 mmarried fbaby (bweight), att

Coarsen the continuous covariates using predefined cutpoints

. kmatch em mbsmoke (10(5)40) mage (0(5)60) fage (asis) prenatal1 mmarried fbaby (bweight), att

Entropy balancing

Balance first moments (means)

. kmatch eb mbsmoke mage fage prenatal1 mmarried fbaby (bweight), att

If successful, entropy balancing perfectly balances the moments (apart from
roundoff error), as can be confirmed by the following command

. kmatch summarize, meanonly

Balance first moments (means), second moments (variances), and covariances

. kmatch eb mbsmoke mage fage prenatal1 mmarried fbaby (bweight), att targets(2) covariances

Treatment effect estimates will be set to 0 and flagged as omitted if
the balancing tolerance cannot be met

. kmatch eb mbsmoke mage fage prenatal1 mmarried fbaby (bweight) if !(prenatal1==0&mbsmoke==0), att

Inverse probability weighting (IPW)

Inverse probability weighting based on a probit model to predict
each subject's propensity score

. kmatch ipw mbsmoke mage fage prenatal1 mmarried fbaby (bweight), pscmd(probit) att

Compare to teffects ipw

. teffects ipw (bweight) (mbsmoke mage fage prenatal1 mmarried fbaby, probit), atet

Inverse-probability-weighted regression adjustment

. kmatch ipw mbsmoke mage fage prenatal1 mmarried fbaby (bweight = mage fage prenatal1 mmarried fbaby), pscmd(probit) att

Compare to teffects ipwra

. teffects ipwra (bweight mage fage prenatal1 mmarried fbaby) (mbsmoke mage fage prenatal1 mmarried fbaby, probit), atet

Regression adjustment

Regression adjustment without matching or reweighting

. kmatch ra mbsmoke (bweight = mage fage prenatal1 mmarried fbaby), att

Compare to teffects ra

. teffects ra (bweight mage fage prenatal1 mmarried fbaby) (mbsmoke), atet

Multiple outcome variables

Multiple outcome variables or, more generally, multiple outcome equations
can be specified in a single call to kmatch. Here is an example
in which the same outcome variable is used twice, once without
regression adjustment and once with regression adjustment:

. kmatch ps mbsmoke mage fage prenatal1 mmarried fbaby (bweight) (bweight = mage fage prenatal1 mmarried fbaby), att

Within each outcome equation multiple outcomes can be specified to reduce
the amount of typing. Here is an example with two outcome variables that are both used
with and without regression adjustment:

. kmatch ps mbsmoke mage fage prenatal1 mmarried fbaby (bweight lbweight = mage fage prenatal1 mmarried fbaby) (bweight lbweight), att

Evaluate balancing by including the covariates as outcomes

. kmatch ps mbsmoke mage fage prenatal1 mmarried fbaby (mage fage prenatal1 mmarried fbaby), att

ATE, ATT, ATC, NATE, and potential outcome means

In the above examples, the average treatment effect on the treated (ATT) was
reported. kmatch can also report the average treatment effect (ATE;
the default), the average treatment effect on the untreated (ATC), the
naive average treatment effect (NATE; i.e. the raw mean difference), as
well as the potential outcome means that stand behind there
quantities. Here is an example in which all of these quantities are
computed in a single call:

. kmatch ps mbsmoke mage fage prenatal1 mmarried fbaby (bweight), ate att atc nate po

Having all quantities in a single estimation set is convenient if you want
to make comparisons:

. test ATT = ATC

. lincom ATE - NATE

Results by subpopulations

Use the over() option to compute results by subpopulations. The
matching/balancing will be performed individually within each subpopulation.

. kmatch ps mbsmoke mage fage prenatal1 mmarried (bweight), att over(fbaby)

. test [0]ATT = [1]ATT

. lincom [0]ATT - [1]ATT

Balancing diagnostics

. kmatch md mbsmoke mage prenatal1 mmarried fbaby (bweight), att

. kmatch summarize

. kmatch density mage

. kmatch cumul mage

. kmatch box mage

. kmatch ps mbsmoke mage prenatal1 mmarried fbaby (bweight), att

. kmatch density

. kmatch cumul

. kmatch box

Common support diagnostics

Depending on situation, not all observations can be matched. Commands
kmatch csummarize, kmatch cdensity, kmatch ccumul,
kmatch cbox can be used to evaluate how matched, unmatched, and the
total sample differ.

. kmatch ps mbsmoke mage fage prenatal1 mmarried fbaby (bweight), att bwidth(0.0005)

. kmatch csummarize

. kmatch cdensity

. kmatch ccumul

. kmatch cbox

Bandwidth selection

Option bwidth() offers several automatic bandwidth selection
methods for kernel matching in kmatch md and
kmatch ps. The default is bwidth(pm), a pair-matching algorithm
as proposed by Huber et al. (2013, 2015). The algorithm typically leads to
rather small bandwidths.

. kmatch ps mbsmoke mmarried mage fbaby medu (bweight), att atc

Typing bwidth(cv) will determine the bandwidth by cross-validation with
respect to the mean of the propensity score (in case of kmatch ps)
or with respect to the means of the covariates (in case of
kmatch md).

. kmatch ps mbsmoke mmarried mage fbaby medu (bweight), att atc bwidth(cv)

Furthermore, bwidth(cv cvvar) will use cross-validation
with respect to cvvar as suggested by Frölich (2004, 2005) and
bwidth(cv cvvar, weighted) will use weighted
cross-validation as suggested by Galdo et al. (2008; Section 4.2). Here is
an example of the former:

. kmatch ps mbsmoke mmarried mage fbaby medu (bweight), att atc bwidth(cv bweight)

The cross-validation algorithm is not guaranteed to find the MISE minimizing
bandwidth as there might be local minima or flat regions. You can use command
kmatch cvplot to view the trace of the search algorithm:

. kmatch cvplot, ms(o o) index mlabposition(1 1) sort

Stored results

kmatch md and kmatch ps store the following in e():

Scalars

e(N) number of observations

e(tval) value of tvar that is the treatment

e(N_ovars) number of outcome variables

e(k_omit) number of omitted estimates

e(N_over) number over-groups

e(N_clust) number of clusters (or undefined)

e(N_outsup) number of obs out of support due to comsup option (or undefined)

e(df_r) residual degrees of freedom (or undefined)

e(ridge) value of ridge parameter (or undefined)

e(nn) number of requested neighbors (or undefined)

e(nn_min) minimum number of neighbors (or undefined)

e(nn_max) maximum number of neighbors (or undefined)

e(pm_quantile) q of PM bandwidth algorithm (or undefined)

e(pm_factor) f of PM bandwidth algorithm (or undefined)

e(cv_factor) step size of CV bandwidth algorithm (or undefined)

e(maxiter) maximum number of iterations for PS estimation (or undefined)

e(btolerance) balancing tolerance (or undefined)

Macros

e(cmd) kmatch

e(subcmd) md, ps, em, eb, ipw, or ra

e(cmdline) command as typed

e(tvar) name of treatment variable

e(xvars) names of main covariates

e(ematch) emvars from ematch() or kmatch em

e(emxvars) exact matching covariates (coarsened variables in brackets)

e(psvars) variable names from psvars()

e(pscore) variable names from pscore()

e(comsup) comsup or contents from comsup() or empty

e(over) name of over variable

e(over_labels) values over variable

e(over_namelist) values over variable

e(ovar#) name of outcome variable #

e(avars#) names of adjustment variables for outcome #

e(generate) names of variables generated by generate()

e(wgenerate) names of variables generated by wgenerate()

e(dygenerate) names of variables generated by dygenerate()

e(idgenerate) names of variables generated by idgenerate()

e(dxgenerate) names of variables generated by dxgenerate()

e(cemgenerate) names of variables generated by cemgenerate()

e(ifgenerate) names of variables generated by ifgenerate()

e(metric) type of multivariate distance metric

e(kernel) type of kernel

e(keepall) keepall or empty

e(wor) wor or empty

e(pscmd) command used for propensity score estimation

e(psopts) options passed through to propensity score estimation

e(pspredict) predict options for propensity score estimation

e(bw_method) bandwidth selection method

e(cv_outcome) name of cross-validation outcome variable

e(cv_weighted) weighted or empty

e(cv_nopenalty) nopenalty or empty

e(cv_nolimit) nolimit or empty

e(cv_exact) exact or empty

e(ebalance) ebalance or empty

e(ebvars) variable names from ebalance()

e(csonly) csonly or empty

e(targets) entropy balancing targets

e(covariances) covariances or empty

e(nconstraint) nconstraint or empty

e(fitopts) entropy balancing options

e(ate) ate or empty

e(att) att or empty

e(atc) atc or empty

e(wtype) weight type

e(wexp) weight expression

e(vce) vcetype from vce()

e(clustvar) clustvar from vce()

e(title) title in estimation output

e(properties) b or b V

Matrices

e(b) treatment effect estimates

e(_N) numbers of observations in over-groups

e(bwidth) bandwidths (or undefined)

e(S) multivariate distance scaling matrix (or undefined)

e(cv) cross-validation results (or undefined)

e(balanced) entropy balancing indicator (or undefined)

e(loss) entropy balancing loss (or undefined)

e(iterations) number of entropy balancing iterations (or undefined)

e(C_varname) cutpoints used to coarsen varname

Functions

e(sample) marks estimation sample

If vce() is bootstrap or jackknife, additional results as described
in help bootstrap and jackknife are stored in e(). If option svy
option is specified, additional results as described
in help svy are stored in e().

kmatch summarize, kmatch csummarize, kmatch density, kmatch cdensity,
kmatch cumul, kmatch ccumul, kmatch box, kmatch cbox return
macro r(refstat) equal to ate, att, or atc. Additionally,
kmatch summarize and kmatch csummarize store the following matrices in r():

r(M) table of means and standardized differences

r(V) table of variances and their ratios; unless sd is specified

r(SD) table of standard deviations and their ratios; if sd is specified

r(SK) table of skewnesses and their differences; if skewness is specified

r(S) vector of standard deviations used for standardization

References

Abadie, A., G.W. Imbens. 2008. On the Failure of the Bootstrap for Matching
Estimators. Econometrica 76(6):1537–1557.

Abadie, A., G.W. Imbens. 2011. Bias-Corrected Matching Estimators for
Average Treatment Effects. Journal of Business & Economic Statistics
29(1):1-11.

Blackwell, M., S. Iacus, G. King, G. Porro. 2009. cem: Coarsened exact
matching in Stata. The Stata Journal 9(4): 524-546.

Frölich, M. 2004. Finite-sample properties of propensity-score matching and
weighting estimators. The Review of Economics and Statistics 86(1):77-90.

Frölich, M. 2005. Matching estimators and optimal bandwidth choice.
Statistics and Computing 15:197-215.

Galdo, J.C., J. Smith, D. Black. 2008. Bandwidth selection and the estimation
of treatment effects with unbalanced data. Annales d'Économie et de Statistique
91/92:89-216.

Greevy, R.A., Jr., C.G. Grijalva, C.L. Roumie, C. Beck, A.M. Hung, H.J.
Murff, X. Liu, M.R. Griffin. 2012. Reweighted Mahalanobis Distance Matching
for Cluster Randomized Trials with Missing
Data. Pharmacoepidemiology and Drug Safety 21(S2):148–154.

Hainmueller, J. (2012). Entropy Balancing for Causal Effects: A
Multivariate Reweighting Method to Produce Balanced Samples in
Observational Studies. Political Analysis
20(1): 25-46. DOI: 10.1093/pan/mpr025

Heckman, J.J., H. Ichimura, P. Todd. 1998. Matching as an Econometric
Evaluation Estimator. The Review of Economic Studies 65(2):261-294.

Heckman, J.J., H. Ichimura, J. Smith, P. Todd. 1998. Characterizing Selection
Bias Using Experimental Data. Econometrica 66(5):1017-1098.

Huber, M., M. Lechner, A. Steinmayr. 2015. Radius matching on the propensity score with
bias adjustment: tuning parameters and finite sample behaviour. Empirical Economics
49:1-31.

Huber, M., M. Lechner, C. Wunsch. 2013. The performance of estimators based on the
propensity score. Journal of Econometrics 175:1-21.

Iacus, S.M., G. King, G. Porro. 2012. Causal Inference without Balance
Checking: Coarsened Exact Matching. Political Analysis
20(1): 1–24. DOI: 10.1093/pan/mpr013

Jann, B. 2019. Influence functions for linear regression (with an application
to regression adjustment). University of Bern Social Sciences Working Papers
32. Available from http://ideas.repec.org/p/bss/wpaper/32.html.

Author

Ben Jann, University of Bern, jann@soz.unibe.ch

Thanks for citing this software as follows:

Jann, B. (2017). kmatch: Stata module for multivariate-distance and
propensity-score matching, including entropy balancing, inverse probability
weighting, (coarsened) exact matching, and regression adjustment. Available from
https://ideas.repec.org/c/boc/bocode/s458346.html.

Also see

Online: help for teffects