There are several ways matchit()
can perform nearest neighbor matching depending on the arguments you give it. By default, it works as follows:
- The propensity score (probability of being treated, i.e., having a 1) is estimated for each unit.
- Treated units are sort in descending order by the propensity score, so units with the highest propensity score are earlier in the list.
- For each treated unit, the untreated unit with the closest propensity score is chosen as a match and then prevented from being used as a match for any other treated unit.
- The matching stops when all treated units receive a match or there are no more untreated units to be used as matches.
When you set being a male to having the value 1, then the propensity score is the probability of being a male, so males with the highest probability of being male are matched first. When you set being a female to having the value 1, then the propensity score is the probability of being a female, so females with the highest probability of being female are matched first. That means different units are being matched in a different order depending on which level is set as 1, which is why you observed such a difference.
This is not the only way to match and not necessarily even the best way. Setting m.order = "closest"
instead finds the closest pairs and matches them regardless of where the units would fall if they were sorted by their propensity score. That means this method is symmetric across treatment values and you should get the same matched set whether male is 1 or female is 1. This is described in the documentation so please read it :)
data.frame(x=...,y=...)
or the output fromdput(head(x))
into a code block), and intended output given that input. Refs: stackoverflow.com/q/5963269, [mcve], and stackoverflow.com/tags/r/info. $\endgroup$