quickmatch
provides functions for constructing
near-optimal generalized full matchings. Generalized full matching is an
extension of the original full matching method to situations with more
intricate study designs. The package is made with large data sets in
mind and derives matchings more than an order of magnitude quicker than
other methods.
quickmatch
is on CRAN and can be installed by
running:
install.packages("quickmatch")
It is recommended to use the stable CRAN version, but the latest development version can be installed directly from Github using devtools:
if (!require("devtools")) install.packages("devtools")
::install_github("fsavje/quickmatch") devtools
The package contains compiled code, and you must have a development
environment to install the development version. (Use
devtools::has_devel()
to check whether you do.) If no
development environment exists, Windows users download and install Rtools and
macOS users download and install Xcode.
# Load package
library("quickmatch")
# Construct example data
<- data.frame(y = rnorm(100),
my_data x1 = runif(100),
x2 = runif(100),
treatment = factor(sample(rep(c("T", "C"), c(25, 75)))))
# Make distances
<- distances(my_data, dist_variables = c("x1", "x2"))
my_distances
### Average treatment effect (ATE)
# Make matching
<- quickmatch(my_distances, my_data$treatment)
my_matching_ate
# Covariate balance
covariate_balance(my_data$treatment, my_data[c("x1", "x2")], my_matching_ate)
# Estimate effect
lm_match(my_data$y, my_data$treatment, my_matching_ate)
### Average treatment effect of the treated (ATT)
# Make matching
<- quickmatch(my_distances, my_data$treatment, target = "T")
my_matching_att
# Covariate balance
covariate_balance(my_data$treatment, my_data[c("x1", "x2")], my_matching_att, target = "T")
# Estimate effect
lm_match(my_data$y, my_data$treatment, my_matching_att, target = "T")