# 1:1 nearest neighbor propensity score matching in R (MatchIt package)

I used 1:1 nearest neighbor propensity score matching in R (MatchIt package) to match samples from an experimental group with a control sample. I used the procedure described here: https://pareonline.net/pdf/v19n18.pdf

Now I wonder if I can identify which 2 people in my dataset are a matched pair. Is it possible to identify the exact "matching partner" in experimental and control group?

## 1 Answer

You need to use the call to $match.matrix after the variable containing your matching results. For example, using the first example in your linked paper, you would issue the following commands: m.out = matchit(stw ~ tot + min + dis, data = mydata, method = "nearest", ratio = 1) m.out$match.matrix


Here's an example with the lalonde dataset:

> m.out<-matchit(treat~age+educ+black, method="nearest", ratio=1, data=lalonde)
> data(lalonde)
> m.out<-matchit(treat~age+educ+black, method="nearest", ratio=1, data=lalonde)
> my.matches<-m.out$match.matrix > head(my.matches) 1 NSW1 "PSID357" NSW2 "PSID62" NSW3 "PSID113" NSW4 "PSID170" NSW5 "PSID280" NSW6 "PSID3"  Note that no other options are needed in this example since the IDs are first in the rownames in the lalonde dataset. You may need to assign IDs to your rownames first by: row.names(lalonde)<-lalonde$my.subject.id


match.matrix An n_1 by ratio matrix where the row names, which can be obtained through row.names(match.matrix), represent the names of the treatment units, which come from the data frame specified in data. Each column stores the name(s) of the control unit(s) matched to the treatment unit of that row. For example, when the ratio input for nearest neighbor or optimal matching is specified as 3, the three columns of match.matrix represent the three control units matched to one treatment unit). NA indicates that the treatment unit was not matched.