CMatching-package | R Documentation |
Provides functions to perform matching algorithms for causal inference with clustered data, as described in B. Arpino and M. Cannas (2016) <doi:10.1002/sim.6880>. Pure within-cluster and preferential within-cluster matching are implemented. Both algorithms provide causal estimates with cluster-adjusted estimates of standard errors.
Package: | CMatching |
Type: | Package |
Version: | 2.4 |
Date: | 2024-02-08 |
License: | GPL version 3 |
Several strategies have been suggested for adapting propensity score matching to clustered data. Depending on researcher's belief about the strength of unobserved cluster level covariates it is possible to take into account clustering either in the estimation of the propensity score model (through the inclusion of fixed or random effects, e.g. Arpino and Mealli (2011)) and/or in the implementation of the matching algorithm (see, e.g. Rickles and Seltzer (2014); Arpino and Cannas (2016)).
This package contains main function CMatch
to adapt classic matching algorithms for causal inference to clustered data and a customized summary
function to analyze the output.
Depending on the type
argument function CMatch
calls either MatchW
implementing a pure within-cluster matching or MatchPW
implementing an approach which can be called "preferential" within-cluster matching. This approach first looks for matchable units within the same cluster and - if no match is found - continues the search in the remaining clusters. The functions also provide causal estimands with cluster-adjusted standard errors from fitting a multilevel model on matched data. CMatch
returns an object of class ”CMatch
” which can be be summarized and used as input of the CMatchBalance
function to examine how much the procedure resulted in improved covariate balance.
Although CMatch
has been designed for dealing with clustered data, these algorithms can be used to force a perfect balance or to improve the balance of categorical variables, respectively. In this case, the "clusters" correspond to the levels of the categorical variable(s). When used for this purpouse the user should ignore the standard error (if provided). Note that Matchby
from package Matching
can be used for the same purpouse.
Massimo Cannas [aut, cre], Bruno Arpino [ctb], Elena Colicino [ctb]. A special thanks to Thomas W. Yee for his help in updating to version 2.1.
Maintainer: Massimo Cannas <massimo.cannas@unica.it>
Sekhon, Jasjeet S. (2011). Multivariate and Propensity Score Matching Software with Automated Balance Optimization. Journal of Statistical Software, 42(7): 1-52. http://www.jstatsoft.org/v42/i07/
Arpino, B., and Cannas, M. (2016). Propensity score matching with clustered data. An application to the estimation of the impact of caesarean section on the Apgar score. Statistics in Medicine, 35: 2074-2091. doi: 10.1002/sim.6880.
Rickles, J. H., and Seltzer, M. (2014). A Two-Stage Propensity Score Matching Strategy for Treatment Effect Estimation in a Multisite Observational Study. Journal of Educational and Behavioral Statistics, 39(6), 612-636. doi: 10.3102/1076998614559748
Arpino, B. and Mealli, F. (2011). The specification of the propensity score in multilevel observational studies. Computational Statistics & Data Analysis, 55(4), 1770-1780. doi: 10.1016/j.csda.2010.11.008
Match
, MatchBalance
# a paper and pencil example with a few units
id <- c(1,2,3,4,5, 6,7,8,9,10)
x <- c( 1,1,1.1,1.1,1.4, 2,1,1,1.3, 1.3 )
t <- c( 1,1,1,1,0, 0,0,0,0, 0 )
g <- c(1,1,2,2,1,1,2,2,2, 2 ) # two groups of four and six units
toy <- t(data.frame(id,g, t,x))
# reorder units by ascending group
toyord <-toy[,order(g)]
x <-toyord["x",]
t <-toyord["t",]
g <- toyord["g",]
# pooled matching
pm <- Match(Y=NULL, Tr=t, X=x, caliper=2,ties=FALSE,replace=FALSE)
# quick look at matched dataset (matched pairs are vertically aligned)
pm$index.treated
pm$index.control
# within matching
wm <- CMatch(type="within",Y=NULL, Tr=t, X=x, Group=g,caliper=2,ties=FALSE,replace=FALSE)
wm$index.treated
wm$index.control
# preferential-within matching
pwm <- CMatch(type="pwithin",Y=NULL, Tr=t, X=x, Group=g, caliper=2,ties=FALSE,replace=FALSE)
pwm$index.treated
pwm$index.control
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.