【发布时间】:2015-05-01 10:13:18
【问题描述】:
因此,请遵循 Matching 包中的示例,尤其是 GenMatch 示例 Link to pdf here
按照这里的例子
library(Matching)
data(lalonde)
attach(lalonde)
X = cbind(age, educ, black, hisp, married, nodegr, u74, u75, re75, re74)
BalanceMat <- cbind(age, educ, black, hisp, married, nodegr, u74, u75, re75, re74,
I(re74*re75))
genout <- GenMatch(Tr=treat, X=X, BalanceMatrix=BalanceMat, estimand="ATE", M=1,
pop.size=16, max.generations=10, wait.generations=1)
Y=re78/1000
mout <- Match(Y=Y, Tr=treat, X=X, Weight.matrix=genout)
summary(mout)
我们看到所有治疗病例都与对照病例相匹配。现在假设我们想要精确匹配已婚状态(或任何其他变量)。但是我们还是想使用之前创建的 GenMatch 矩阵。
参考链接
Exact = .....如果提供了逻辑向量,则应为 X 中的每个协变量提供一个逻辑值。使用逻辑向量允许用户为某些变量指定精确匹配,但不能为其他变量指定精确匹配。当未找到完全匹配时,将丢弃观察结果。
所以下面的说法正确吗??
mout2 <- Match(Y=Y, Tr=treat, X=X, exact=c(0,0,0,0,1,0,0,0,0,0), Weight.matrix=genout)
summary(mout2)
我会说不正确,好像你比较
summary(mout$weights)
summary(mout2$weights)
你得到相同的值
【问题讨论】: