The matchitmice()
function enables parametric models for causal inference to work better by selecting matched subsets of the control and treatment groups of imputed datasets of a mids
class object.
matchitmice(formula, datasets, approach = "within", method = "nearest",
distance = "logit", distance.options = list(), discard = "none",
reestimate = FALSE, ...)
This argument takes the usual syntax of R formula, y ~ x1 + x2
, where y
is a binary treatment indicator and x1
and x2
are the matching covariates. Both the treatment indicator and matching covariates must be contained in the imputed datasets, which are specified as datasets
(see below). All of the usual R syntax for formula works. For example, x1:x2
represents the first order interaction term between x1
and x2
and I(x1^2)
represents the square term of x1
. See help(formula)
for details.
This argument specifies the datasets containing the treatment indicator and matching covariates called in the formula
. This argument must be an object of the mids
class, which is typically produced by a previous call to mice()
or mice.mids()
functions from the mice package.
This argument specifies a matching approach. Currently, "within"
(calculating distance measures and matching based on them within each imputed dataset) and "across"
(calculating distance measures within each imputed dataset, averaging distance measure for each observation across imputed datasets, and matching based on the averaged measures in each imputed dataset) approaches are available. The default is "within"
.
This argument specifies a matching method. Currently, "nearest"
(nearest neighbor matching) and "exact"
(exact matching) methods are available. The default is "nearest"
. Note that within each of these matching methods, MatchIt.mice offers a variety of options.
This argument specifies the method used to estimate the distance measure. The default is logistic regression, "logit"
. A variety of other methods are available.
This optional argument specifies the optional arguments that are passed to the model for estimating the distance measure. The input to this argument should be a list.
This argument specifies whether to discard observations that fall outside some measure of support of the distance score before matching, and not allow them to be used at all in the matching procedure. Note that discarding observations may change the quantity of interest being estimated. The current options are "none"
(discarding no observations before matching), "both"
(discarding all observations, both the control and treatment observations, that are outside the support of the distance measure), "control"
(discarding only control observations outside the support of the distance measure of the treatment observations), and "treat"
(discarding only treatment observations outside the support of the distance measure of the control observations). The default is "none"
.
This argument specifies whether the model for estimating the distance measure should be reestimated after observations are discarded. The input must be a logical value. The default is FALSE
.
Additional arguments to be passed to the matching method.
This function returns an object of the mimids
(matched multiply imputed datasets) class, that includes matched subsets of the imputed datasets primarily passed to the function by the datasets
argument.
The matching is done using the matchitmice(y ~ x1, ...)
command, where y
is the vector of treatment assignments and x1
represents the covariates to be used in the matching model. There are a number of matching options, detailed below. The default syntax is matchitmice(formula, datasets = NULL, method = "nearest", model = "logit", ratio = 1, caliper = 0, ...)
. Summaries of the results can be seen graphically using plot()
or numerically using summary()
functions. The print()
function also prints out the output.
Daniel Ho, Kosuke Imai, Gary King, and Elizabeth Stuart (2007). Matching as Nonparametric Preprocessing for Reducing Model Dependence in Parametric Causal Inference. Political Analysis, 15(3): 199-236. http://gking.harvard.edu/files/abs/matchp-abs.shtml
Stef van Buuren and Karin Groothuis-Oudshoorn (2011). mice
: Multivariate Imputation by Chained Equations in R
. Journal of Statistical Software, 45(3): 1-67. https://www.jstatsoft.org/v45/i03/
# NOT RUN {
#Loading the 'dt.osa' dataset
data(dt.osa)
#Imputing missing data points in the'dt.osa' dataset
datasets <- mice(dt.osa, m = 5, maxit = 1,
method = c("", "", "mean", "", "polyreg", "logreg", "logreg"))
#Matching the imputed datasets, 'datasets'
matcheddatasets <- matchitmice(KOA ~ SEX + AGE + SMK, datasets,
approach = 'within', method = 'exact')
# }
Run the code above in your browser using DataLab