Get only the fully matched cases using Matchit in R using 1:5 ratio

918 Views Asked by At

I have matched my two groups with 1:5 ratio and noticed that my two resulting groups do not have a 1:5 ratio, similar to this question posted here:

3:1 matching with MatchIt in R. The number of matched control is not equal to 3 times the number of cases

I have performed a match like this:

    match_out <- matchit(as.formula(paste0("treat~",covar)),
                      data = data, replace = FALSE,
                      caliper = .2, ratio = 5, method = "nearest") 

And my ouput looks like this:

> match_out 

Call: 
matchit(formula = as.formula(paste0("treat~", covar)), data = data, 
    method = "nearest", replace = FALSE, caliper = 0.2, ratio = 5)

Sample sizes:
          Control Treated
All          7594      13
Matched        42      10
Unmatched    7552       3
Discarded       0       0


> match_out$match.matrix
     1      2      3      4      5     
14   "3891" NA     NA     NA     NA    
300  "5160" "2282" "2634" "6349" NA    
578  "5343" "5486" "4433" "2026" "249" 
997  "1121" "3928" "6464" "5015" "1863"
1534 NA     NA     NA     NA     NA    
1787 "7517" "7053" "5187" "4157" "919" 
4016 "525"  "5514" NA     NA     NA    
4082 "5548" "2951" "7282" "3378" "2642"
4894 "1009" "6386" "946"  "1819" "1727"
5812 NA     NA     NA     NA     NA    
5954 "7298" "6898" "1503" "7004" "7110"
6825 NA     NA     NA     NA     NA    
7389 "4286" "3044" "985"  "1471" "3591"

As I understand it correctly, my output now contains all the cases where a match of at least one has occured.

Now I would like to know, if there an (easy) way to get only those that have a full match of 5 Controls per 1 Treated (which would be 7 in my case).

2

There are 2 best solutions below

0
On BEST ANSWER

To restrict to just the units who have exactly 5 matches, you can just run na.omit() on the match.matrix output. That will produce a matrix with just the treated and control units who have all 5 matches. From there you can subset the match.data() output to get just those you need, e.g.,

m_data <- match.data(match_out, data = data)

mm <- na.omit(match_out$match.matrix)

m_data <- m_data[rownames(m_data) %in% rownames(mm) |
                   rownames(m_data) %in% mm,]

You can then run your effect estimation in m_data. Note that what you are proposing is not a very good idea; you are needlessly discarding units with no apparent benefit.

1
On

Just to answer my own question: It seems like you can force a full 1:5 match by adding: method = "optimal" to the function. Read more here: https://cran.r-project.org/web/packages/MatchIt/vignettes/matching-methods.html#optimal-pair-matching-method-optimal

This however will decrease the success of matching. Would anyone know a way of selecting only those 1:5 cases from the original output?

EDIT: As Noah pointed out, the 1:5 match can be forced, but this will ignore the caliper. See the documentation here: https://rdrr.io/cran/MatchIt/man/method_optimal.html I thought it was a bit hidden, but you can see under the header "Arguments" it says: "The arguments replace, caliper, and m.order are ignored with a warning."