CMatchBalance {CMatching}R Documentation

Analyze covariate balance before and after matching.


Generic function for analyzing covariate balance. If match.out is NULL only balance statistics for the unmatched data are returned otherwise both before and after matching balance are given. The function is simply a wrapper calling MatchBalance, possibly after coercing the class of match.out. See MatchBalance for more detailed description.


CMatchBalance(match.out, formula, data = NULL, ks = TRUE, 
nboots = 500, weights = NULL, digits = 5, paired = TRUE, print.level = 1)



A matched data set, i.e., the result of a call to Match or CMatch.


This formula does not estimate a model. It is a compact way to describe which variables should be compared between the treated and control group. See MatchBalance.


An optional data set for the variables indicated in the formula argument.


A flag for whether Kolmogorov-Smirnov tests should be calculated.


A vector of observation-specific weights.


The number of bootstrap replication to be used.


The number of digits to be displayed in the output


A flag for whether a paired t.test should be used for the matched data. An unpaired t.test is always used for unmatched data.


The amount of printing, taking values 0 (no printing), 1(summary) and 2 (dtailed results). Default to 1.


The function is a wrapper of the MatchBalance function. If match.out is of class Match (or NULL) then it calls MatchBalance. If match.out is of classCMatch then it coerces the class to Match before calling MatchBalance. This function is meant to exploit MatchBalance for CMatch objects for which MatchBalance would not work.


Balance statistics for the covariates specified in the right side of formula argument. Statistics are compared between the two groups specified by the binary variable in the left side of formula.


Massimo Cannas <> and a special thanks to Thomas W. Yee for his precious help.


Sekhon, Jasjeet S. 2011. Multivariate and Propensity Score Matching Software with Automated Balance Optimization. Journal of Statistical Software 42(7): 1-52.

See Also



# Kreft and De Leeuw, Introducing Multilevel Modeling, Sage (1988).   
# The data set is the subsample of NELS-88 data consisting of 10 handpicked schools
# from the 1003 schools in the full data set.
# Suppose that the effect of homeworks on math score is unconfounded conditional on X 
# and unobserved school features (we assume this only for illustrative purpouse).

# Let us consider the following variables:

X<-schools$ses # or X<-as.matrix(schools[,c("ses","white","public")])
# When Group is missing or there is only one Group CMatch returns 
# the output of the Match function with a warning.

# Let us assume that the effect of homeworks (Tr) on math score (Y)
# is unconfounded conditional on X and other unobserved school features.
# Several strategies to handle unobserved group characteristics
# are described in Arpino & Cannas, 2016 (see References). 

# Multivariate Matching on covariates in X 
# default parameters: one-to-one matching on X with replacement with a caliper of 0.25.

### Matching within schools
 mw<-CMatch(type="within",Y=Y, Tr=Tr, X=X, Group=Group, caliper=0.1)
 # compare balance before and after matching
 bmw  <- CMatchBalance(Tr~X,data=schools,match.out=mw)
 # calculate proportion of matched observations
 # check number of drops by school
### Match preferentially within school 
# i.e. first match within schools
# then (try to) match remaining units between schools
 mpw <- CMatch(type="pwithin",Y=schools$math, Tr=Tr, X=schools$ses, 
 Group=schools$schid, caliper=0.1)

# examine covariate balance
  bmpw<- CMatchBalance(Tr~ses,data=schools,match.out=mpw)
  # equivalent to MatchBalance(...) with mpw coerced to class "Match"

# proportion of matched observations
  (mpw$orig.treated.nobs-mpw$ndrops) / mpw$orig.treated.nobs 
# check drops by school
# proportion of matched observations after match-within only
 (mpw$orig.treated.nobs-sum(mpw$ / mpw$orig.treated.nobs

[Package CMatching version 2.3.0 Index]