如何获取摘要中的Pair Distance列(MatchIt)
How to obtain Pair Distance column in summary (MatchIt)
我正在尝试比较不同的 CEM 匹配,不幸的是 MatchIt 包没有 L 统计量,因此我想比较可以通过汇总函数获得的配对距离列
如何只打印该列? (由于我在原始数据集上进行了多次试验,并且变量很多,所以我想避免复制和粘贴)
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)
我得到的结果
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
我希望得到一个或多或少这样的table
cem1 cem2
Pair. Dist. Pair. Dist.
age 0.1616 0.2364
re74 0.1289 0.1321
re75 0.1671 0.1617
summary()
输出只是一个列表。您可以使用 str()
.
查看其详细信息
要仅获取感兴趣的列,请使用以下命令:
cbind(
summary(cem1)$sum.matched[,"Std. Pair Dist."],
summary(cem2)$sum.matched[,"Std. Pair Dist."]
)
我正在尝试比较不同的 CEM 匹配,不幸的是 MatchIt 包没有 L 统计量,因此我想比较可以通过汇总函数获得的配对距离列
如何只打印该列? (由于我在原始数据集上进行了多次试验,并且变量很多,所以我想避免复制和粘贴)
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)
我得到的结果
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
我希望得到一个或多或少这样的table
cem1 cem2
Pair. Dist. Pair. Dist.
age 0.1616 0.2364
re74 0.1289 0.1321
re75 0.1671 0.1617
summary()
输出只是一个列表。您可以使用 str()
.
要仅获取感兴趣的列,请使用以下命令:
cbind(
summary(cem1)$sum.matched[,"Std. Pair Dist."],
summary(cem2)$sum.matched[,"Std. Pair Dist."]
)