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:
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).
To restrict to just the units who have exactly 5 matches, you can just run
na.omit()
on thematch.matrix
output. That will produce a matrix with just the treated and control units who have all 5 matches. From there you can subset thematch.data()
output to get just those you need, e.g.,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.