I'm trying to compare different CEM matchings, unfortunately the MatchIt package does not have the L statistic therefore I wanted to compare the Pair Distance conlumn that can be obained with the summary function
How can I print only that column? (Since I apply several trials in the original dataset and the variables are a lot I would like to avoid copy and paste)
library(tidyverse)
library(MatchIt)
data(lalonde)
cem1 <- matchit(treat ~ age + re74 + re75, data = lalonde,
method = "cem")
cem2 <- matchit(treat ~ age + re74 + re75, data = lalonde,
method = "cem",
cutpoints= list(age = c(20.5, 25.5, 30.5,35.5,40.5))
)
summary(cem1, un=TRUE)
summary(cem2, un=TRUE)
resutls I get
Call:
matchit(formula = treat ~ age + re74 + re75, data = lalonde,
method = "cem", cutpoints = list(age = c(20.5, 25.5, 30.5,
35.5, 40.5)))
Summary of Balance for All Data:
Means Treated Means Control Std. Mean Diff. Var. Ratio eCDF Mean eCDF Max
age 25.8162 28.0303 -0.3094 0.4400 0.0813 0.1577
re74 2095.5737 5619.2365 -0.7211 0.5181 0.2248 0.4470
re75 1532.0553 2466.4844 -0.2903 0.9563 0.1342 0.2876
Summary of Balance for Matched Data:
Means Treated Means Control Std. Mean Diff. Var. Ratio eCDF Mean eCDF Max Std. Pair
Dist.
age 25.6286 25.8312 -0.0283 0.6863 0.0222 0.0619 0.2364
re74 1299.0813 1755.5500 -0.0934 1.1026 0.0672 0.3764 0.1321
re75 1016.9323 1228.5970 -0.0657 1.0062 0.0471 0.1852 0.1617
Percent Balance Improvement:
Std. Mean Diff. Var. Ratio eCDF Mean eCDF Max
age 90.8 54.1 72.7 60.8
re74 87.0 85.1 70.1 15.8
re75 77.3 86.2 64.9 35.6
Sample Sizes:
Control Treated
All 429. 185
Matched (ESS) 169.79 175
Matched 288. 175
Unmatched 141. 10
Discarded 0. 0
what I would like to get a table like this one more or less
cem1 cem2
Pair. Dist. Pair. Dist.
age 0.1616 0.2364
re74 0.1289 0.1321
re75 0.1671 0.1617
The summary()
output is just a list. You can look at its details using str()
.
To get just the columns of interest, use the following:
cbind(
summary(cem1)$sum.matched[,"Std. Pair Dist."],
summary(cem2)$sum.matched[,"Std. Pair Dist."]
)