【发布时间】:2022-02-23 01:02:22
【问题描述】:
我分别使用R包“Matching”和“Matchit”在R中进行了倾向得分匹配,但匹配的数量完全不同。
数据集在这里http://web.hku.hk/~bcowling/data/propensity.csv 或http://web.hku.hk/~bcowling/examples/propensity.htm。
example <- propensity
使用“匹配”的代码是:
m.ps <- glm(trt ~ age + risk + severity, family="binomial", data=example)
example$ps <- predict(m.ps, type="response")
PS.m <- Match(Y=example$death, Tr=example$trt, X=example$ps, M=1, caliper=0.2, replace=FALSE)
summary(PS.m )
SE......... 0.041299
T-stat..... -2.1126
p.val...... 0.034634
Original number of observations.............. 400
Original number of treated obs............... 192
Matched number of observations............... 149
Matched number of observations (unweighted). 149
Caliper (SDs)........................................ 0.2
Number of obs dropped by 'exact' or 'caliper' 43
匹配数为 149。
使用“MatchIt”的代码是:
psm<-matchit(trt ~ age+risk+severity, data=example, method="nearest",caliper=0.2)
summary(psm)
Sample Sizes:
Control Treated
All 208 192
Matched 161 161
Unmatched 47 31
Discarded 0 0
匹配数为 161,与使用 Matching 时的 149 不同。 为什么它们不同?
【问题讨论】:
标签: r match matching propensity-score-matching