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
The identity of units within a match are stored in the
match.matrix
component of thematchit
output object. This is a matrix with as many rows as there are treated units and withratio
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:Treated unit
NSW1
is matched with control unitsPSID305
andPSID369
. If the original dataset did not have row names, the values correspond to the row of the dataset where the corresponding unit appears.