I'm first trying this out in R Studio with a small practice dataset found here (584 obs, 5 variables) (https://scholarworks.umass.edu/cgi/viewcontent.cgi?article=1330&context=pare)

Using this code I can use nearest neighbor matching to find the mean difference in matched cases and controls (1:1) where stw is my grouping variable and tot, min, and dis are the matching variables:

m.out = matchit(stw ~ tot + min + dis,
                data = mydata, method = "nearest",
                ratio = 1)

what I want to know is how can I view which cases have matched with which controls (i.e. shows me the exact identity)?

I would also like to do this where I match 5 nearest neighbors (i.e. ratio = 5) and also view those exact identities. is there additional code needed for this?

many thanks

1

There are 1 best solutions below

0
On BEST ANSWER

The identity of units within a match are stored in the match.matrix component of the matchit output object. This is a matrix with as many rows as there are treated units and with ratio columns. Each row corresponds to a treated unit, and the values in the row correspond to the identity of the control unit matched to that treated unit. Below is an example:

> head(m$match.matrix)
     1         2        
NSW1 "PSID305" "PSID369"
NSW2 "PSID198" "PSID273"
NSW3 "PSID333" "PSID282"
NSW4 "PSID400" "PSID92" 
NSW5 "PSID426" "PSID262"
NSW6 "PSID391" "PSID261"

Treated unit NSW1 is matched with control units PSID305 and PSID369. If the original dataset did not have row names, the values correspond to the row of the dataset where the corresponding unit appears.