Here, we present examples for using match.data(). Users can run these commands by typing demo(match.data) at the R prompt. First, we load the Lalonde data,
> data(lalonde)
The next line performs nearest neighbor matching based on the estimated propensity score from the logistic regression,
> m.out1 <- matchit(treat ~ re74 + re75 + age + educ, data = lalonde, + method = "nearest", distance = "logit")
To obtain matched data, type the following command,
> m.data1 <- match.data(m.out1)
It is easy to summarize the resulting matched data,
> summary(m.data1)
To obtain matched data for the treatment or control group, specify the option group as follows,
> m.data2 <- match.data(m.out1, group = "treat") > summary(m.data2) > m.data3 <- match.data(m.out1, group = "control") > summary(m.data3)
We can also use the function to return unmatched data:
> unmatched.data <- lalonde[!row.names(lalonde)%in%row.names(match.data(m.out1)),]
We can also specify different names for the subclass indicator, the weight variable, and the estimated distance measure. The following example first does a subclassification method, obtains the matched data with specified names for those three variables, and then print out the names of all variables in the resulting matched data.
> m.out2 <- matchit(treat ~ re74 + re75 + age + educ, data = lalonde, + method = "subclass") > m.data4 <- match.data(m.out2, subclass = "block", weights = "w", + distance = "pscore") > names(m.data4)