根据Matching包中的示例,特别是GenMatch示例(pdf链接)
请按照此处的示例进行操作。
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)
您会得到相同的值。