I have created a Matched Cohort using MatchIt package in R. I have the list of members who are in the treatment group and the control group. But I am unable to figure out which treatment subject is matched to which control group. Can somebody please point me to this? It is very important for me.

Thanks in advance.

  • 4
    $\begingroup$ It would be better to give an example of your code and/or your results if you want to have a good answer. $\endgroup$
    – PAC
    Jul 31, 2013 at 12:58

3 Answers 3

# I used mahalanobis distance here for nearest neighborhood matching and 
#  data nuclear plants
zz <- matchit(pr ~ t1 + t2, data=nuclearplants, method="nearest", 
              distance="mahalanobis", replace=TRUE)
> zz
Call:  matchit(formula = pr ~ t1 + t2, data = nuclearplants, method = "nearest", 
               distance = "mahalanobis", replace = TRUE)

Sample sizes:
          Control Treated
All            22      10
Matched         6      10
Unmatched      16       0
Discarded       0       0

zz.out <- zz$match.matrix  # This gives us the matched matrix
> zz.out
A "I"
B "N"
C "M"
D "V"
E "X"
F "Z"
G "Z"
a "N"
b "N"
c "I"

Note: The first column are treated subjects and second column are control subjects. As you can see from zz there are only 6 matched controls and 10 matched treated.For instance,B,a,and b treated are matched to control N, and so on. To obtain the matched data use match.data(zz).

  • $\begingroup$ Glad that it worked for you. $\endgroup$
    – Metrics
    Jul 31, 2013 at 18:24

One important detail that may not be clear from the answer above is that the default form of matching in the matchit package (and in much of the scholarly literature in any field) is to use a propensity score that estimates, for each observation, the probability of assignment to treatment given some set of pre-treatment covariates using logistic regression.

While the default one-to-one nearest neighbor propensity score matching method in matchit will select the control observation with the smallest distance to a given treated observation, the resulting matched data is not paired in the way that the questioner imagines. The logit-based propensity score method collapses the multidimensional pre-treatment data to a unidimensional zero to one scale and identifies the appropriate control(s) for the treated observations. The end result is generally treated and control groups with greater overlap in their propensity scores but it is possible for a treated and a control unit to have propensity scores that are relatively far apart if, at that stage of the matching, a far away control has the shortest distance to the treated observation in question (this assumes matching without replacement or replace=FALSE in matchit syntax).

As a result, there is no guarantee with the default settings of matchit(method="nearest", distance="logit") that a matched cohort will be produced in which each treated unit is closely paired with a specific control unit. If one uses the caliper feature of matchit (e.g., caliper=.1), then the matched treated and control units will always be within the caliper's distance of each other, more closely approximating a paired cohort.

When matchit has distance set to 'mahalanobis', not only is the distance calculation different but it operates with something like the caliper so that pairs of treated and control units are plausibly proximate. Hence the use of distance='mahalanobis' above works to create a matched cohort of treated and control observations.

To see a visual representation of how nearest neighbor matching differs when distance calculated via logit vs via mahalanobis distance, see these slides from Gary King, one of the co-authors of the matchit package: http://gking.harvard.edu/presentations/simplifying-matching-methods-causal-inference-1


It is also important to note that PS matching is not a paired matching, hence, there is no need to use such as conditional logistic regression/clustering in an attempt to take in to account the "paired nature" of the data unlike pair-wise matching. It is distributional assumption that in expectation the distribution a of covariates included in the PS model are balanced between treated and untreated groups.

However, when matching was done with replacement, the weights for subjects would be different from 1 and hence the weights should be accounted for as in inverse probability of treatment weighting - matching is a special case of weighting.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.