Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kosukeimai/MatchIt
R package MatchIt
https://github.com/kosukeimai/MatchIt
Last synced: 3 months ago
JSON representation
R package MatchIt
- Host: GitHub
- URL: https://github.com/kosukeimai/MatchIt
- Owner: kosukeimai
- Created: 2017-02-23T02:03:41.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2024-01-22T22:36:05.000Z (10 months ago)
- Last Synced: 2024-07-21T03:21:27.123Z (4 months ago)
- Language: R
- Size: 62.8 MB
- Stars: 200
- Watchers: 7
- Forks: 42
- Open Issues: 20
-
Metadata Files:
- Readme: README.Rmd
Awesome Lists containing this project
README
---
output: github_document
---```{r, echo = FALSE}
knitr::opts_chunk$set(
collapse = FALSE,
warning = FALSE,
message = FALSE,
tidy = FALSE,
fig.align='center',
comment = "#>",
fig.path = "man/figures/README-",
R.options = list(width = 200)
)
```
# MatchIt: Nonparametric Preprocessing for Parametric Causal Inference[![CRAN_Status_Badge](https://img.shields.io/cran/v/MatchIt?color=952100)](https://cran.r-project.org/package=MatchIt) [![CRAN_Downloads_Badge](https://cranlogs.r-pkg.org/badges/MatchIt?color=952100)](https://cran.r-project.org/package=MatchIt)
------
### Overview`MatchIt` provides a simple and straightforward interface to various methods of matching for covariate balance in observational studies. Matching is one way to reduce confounding and model dependence when estimating treatment effects. Several matching methods are available, including nearest neighbor matching, optimal pair matching, optimal full matching, generalized full matching, genetic matching, exact matching, coarsened exact matching, cardinality matching, and subclassification, some of which rely on functions from other R packages. A variety of methods to estimate propensity scores for propensity score matching are included. Below is an example of the use of `MatchIt` to perform Mahalanobis distance matching with replacement and assess balance:
```{r}
library("MatchIt")
data("lalonde", package = "MatchIt")# 1:1 nearest neighbor matching with replacement on
# the Mahalanobis distance
m.out <- matchit(treat ~ age + educ + race + married +
nodegree + re74 + re75,
data = lalonde, distance = "mahalanobis",
replace = TRUE)
```Printing the `MatchIt` object provides details of the kind of matching performed.
```{r}
m.out
```We can check covariate balance for the original and matched samples using `summary()`:
```{r}
#Checking balance before and after matching:
summary(m.out)
```At the top is balance for the original sample. Below that is balance in the matched sample, followed by the percent reduction in imbalance and the sample sizes before and after matching. Smaller values for the balance statistics indicate better balance. (In this case, good balance was not achieved and other matching methods should be tried). We can plot the standardized mean differences in a Love plot for a clean, visual display of balance across the sample:
```{r, fig.alt ="Love plot of balance before and after matching."}
#Plot balance
plot(summary(m.out))
```Although much has been written about matching theory, most of the theory relied upon in `MatchIt` is described well in [Ho, Imai, King, and Stuart (2007)](https//:doi.org/10.1093/pan/mpl013), [Stuart (2010)](https://doi.org/10.1214/09-STS313), and [Greifer and Stuart (2021)](https://doi.org/10.1093/epirev/mxab003). The *Journal of Statistical Software* article for `MatchIt` can be accessed [here](https://doi.org/10.18637/jss.v042.i08), though note that some options have changed, so the `MatchIt` reference pages and included vignettes should be used for understanding the functions and methods available. Further references for individual methods are present in their respective help pages. The `MatchIt` [website](https://kosukeimai.github.io/MatchIt/) provides access to vignettes and documentation files.
### Citing `MatchIt`
Please cite `MatchIt` when using it for analysis presented in publications, which you can do by citing the *Journal of Statistical Software* article below:
Ho, D. E., Imai, K., King, G., & Stuart, E. A. (2011). MatchIt: Nonparametric Preprocessing for Parametric Causal Inference. *Journal of Statistical Software*, 42(8). [doi:10.18637/jss.v042.i08](https://doi.org/10.18637/jss.v042.i08)
This citation can also be accessed using `citation("MatchIt")` in R. For reproducibility purposes, it is also important to include the version number for the version used.
### Installation
To download and install the latest stable version of `MatchIt` from CRAN, run the following:
```{r, eval=F}
install.packages("MatchIt")
```To install a development version, which may have a bug fixed or a new feature, run the following:
```{r, eval=F}
install.packages("remotes") #If not yet installedremotes::install_github("ngreifer/MatchIt")
```This will require R to compile C++ code, which might require additional software be installed on your computer. If you need the development version but can't compile the package, ask the maintainer for a binary version of the package.