Matching包中生成的权重矩阵是什么?

What is the Weight Matrix generated in the Matching package?

参考Matching包,我们看一下使用GenMatch的例子。

我们读到创建的Weight Matrix一个矩阵,其对角线对应于X

中每个变量的权重

但我们不确定生成的值代表什么 - 它们是否与标准差有关。

让我们以 GenMatch

中提供的示例为例
library(Matching)
data(lalonde)
attach(lalonde)
#The covariates we want to match on
X = cbind(age, educ, black, hisp, married, nodegr, u74, u75, re75, re74)
#The covariates we want to obtain balance on
BalanceMat <- cbind(age, educ, black, hisp, married, nodegr, u74, u75, re75, re74,
I(re74*re75))
#Let's call GenMatch() to find the optimal weight to give each
#covariate in 'X' so as we have achieved balance on the covariates in
#'BalanceMat'. This is only an example so we want GenMatch to be quick
#so the population size has been set to be only 16 via the 'pop.size'
#option. This is *WAY* too small for actual problems.
#For details see http://sekhon.berkeley.edu/papers/MatchingJSS.pdf.
#
genout <- GenMatch(Tr=treat, X=X, BalanceMatrix=BalanceMat, estimand="ATE", M=1,
pop.size=16, max.generations=10, wait.generations=1)

然后我们可以输出Weight.matrix,后面会用到配对数据

genout$Weight.matrix

特别是分配给 age

的值
genout$Weight.matrix[1,1]

我们得到的值为 ~205。但是这个重量是什么意思或代表什么?

此外,如果我们要随机化数据的顺序,值会不断变化。

n <- 100
P1 <- rep(NA, n)
for (i in 1:n) {

  lalonde <- lalonde[sample(1:nrow(lalonde)), ] # randomise order

  X = cbind(lalonde$age, lalonde$educ, lalonde$black, lalonde$hisp, 
            lalonde$married, lalonde$nodegr, lalonde$u74, lalonde$u75, 
            lalonde$re75, lalonde$re74)

  BalanceMat <- cbind(lalonde$age, lalonde$educ, lalonde$black, 
                      lalonde$hisp, lalonde$married, lalonde$nodegr, 
                      lalonde$u74, lalonde$u75, lalonde$re75, lalonde$re74, 
                      I(lalonde$re74*lalonde$re75))

  genout <- GenMatch(Tr=lalonde$treat, X=X, BalanceMatrix=BalanceMat, estimand="ATE", M=1,
                     pop.size=16, max.generations=10, wait.generations=1)

  P1[i] <- genout$Weight.matrix[1,1]

}

该论文的作者还建议 additional information 可能会有帮助,但它没有解释 weight matrix 值代表什么。任何人都可以解释它们或理解为什么当数据顺序不同时它们的大小会发生变化

不幸的是,这不是一个可以很容易回答的问题(但要回答你的部分问题,不,权重矩阵的值与标准偏差无关).

GenMatch是一种仿射不变匹配算法,它使用距离度量d(),其中W[=34=的所有元素] 除了沿着主对角线向下外都是零。主对角线由必须选择的 k 个参数组成。 (请注意,如果这些 k 参数中的每一个都设置为等于 1,则 d() 与马哈拉诺比斯距离相同)。与马氏距离一样,该距离度量可用于进行贪婪或最优完全匹配。 (选择将 W 的非对角线元素设置为零仅仅是出于计算能力的原因)

当数据的顺序变化时量级变化的原因是权重矩阵W有无穷个等价解。产生的匹配对于距离测量的恒定比例变化是不变的。特别是,对于任何正标量 c,每个 W = cW 产生的匹配都是相同的,因此矩阵可以是 以多种方式唯一标识。

为了完全理解权重矩阵的非零元素是如何计算的,我建议阅读 GenMatch 公式背后的 full article ,它有点深入和复杂地看使用的方法。

如果您只是对源代码感兴趣,可以在 GitHub 上查看。如果您对 R 特定代码有其他问题,我很乐意尝试回答它们,但是如果您对权重矩阵生成背后的算法有更多问题,您可能需要前往 Cross Validated。