【问题标题】:R: Propensity Score Matching using MatchIt. How to find the number of matched observations with replace = TRUE?R:使用 MatchIt 进行倾向得分匹配。如何使用replace = TRUE找到匹配观察的数量?
【发布时间】:2019-09-24 07:32:54
【问题描述】:

请考虑以下几点:

我正在将数据与 R 中的 MatchIt 包进行匹配。我的控件数量少于处理的控件,并使用选项 replace = TRUE。根据manual,权重告诉我们匹配控件的频率。

来自手册:

"用replacement匹配,用replace = TRUE。用replacement匹配后,可以用权重来反映频率 每个控制单元都与之匹配。”

但是,我不明白为什么权重可以有小数以及如何反映频率。

例如,我在手册中的示例中添加了replace == TRUE(参见第18页):

library("dplyr")
library("MatchIt")

m.out1 <- matchit(treat ~ re74 + re75 + age + educ, data = lalonde,
 method = "nearest", distance = "logit", replace = T)

tail(match.data(m.out1), 15)
#>         treat age educ black hispan married nodegree re74 re75      re78
#> PSID388     0  19   11     1      0       0        1    0    0 16485.520
#> PSID390     0  48   13     0      0       1        0    0    0     0.000
#> PSID392     0  17   10     1      0       0        1    0    0     0.000
#> PSID393     0  38   12     0      0       1        0    0    0 18756.780
#> PSID396     0  48   14     0      0       1        0    0    0  7236.427
#> PSID398     0  17    8     1      0       0        1    0    0  4520.366
#> PSID400     0  37    8     1      0       0        1    0    0   648.722
#> PSID401     0  17   10     1      0       0        1    0    0  1053.619
#> PSID407     0  23   12     0      0       0        0    0    0  3902.676
#> PSID409     0  17   10     0      0       0        1    0    0 14942.770
#> PSID411     0  18   10     1      0       0        1    0    0  5306.516
#> PSID413     0  17   10     0      0       1        1    0    0  3859.822
#> PSID419     0  51    4     1      0       0        1    0    0     0.000
#> PSID423     0  27   10     1      0       0        1    0    0  7543.794
#> PSID425     0  18   11     0      0       0        1    0    0 10150.500
#>          distance weights
#> PSID388 0.4067545     0.6
#> PSID390 0.4042321     1.2
#> PSID392 0.3974677     0.6
#> PSID393 0.4016920     4.2
#> PSID396 0.4152715     0.6
#> PSID398 0.3758217     1.8
#> PSID400 0.3595084     0.6
#> PSID401 0.3974677     1.2
#> PSID407 0.4144044     1.8
#> PSID409 0.3974677     0.6
#> PSID411 0.3966277     1.2
#> PSID413 0.3974677     1.2
#> PSID419 0.3080590     0.6
#> PSID423 0.3890954     1.2
#> PSID425 0.4076015     1.2

对于控件“PSID393”,权重为 4.276。因此,我假设这个控件匹配了 4 或 5 次(四舍五入后)。

不过,我们也可以查看match.matrix,一一查看匹配的治疗和对照。过滤“PSID393”,我们看到控件实际上已经匹配了7次:

m.out1$match.matrix %>% data.frame() %>% filter(X1 == "PSID393")


#>        X1
#> 1 PSID393
#> 2 PSID393
#> 3 PSID393
#> 4 PSID393
#> 5 PSID393
#> 6 PSID393
#> 7 PSID393

reprex package (v0.2.1) 于 2019 年 5 月 6 日创建

如何正确解释这两个输出?

【问题讨论】:

    标签: r matching nearest-neighbor propensity-score-matching


    【解决方案1】:

    权重经过缩放,以便它们总和为对照组中唯一匹配的观察值的数量。使用您的示例数据,请注意权重的总和等于观察次数,平均权重为 1。此外,最常用的观察的权重是最少使用的观察的权重的 7 倍):

    match.data(m.out1) %>%
      group_by(treat) %>% 
      summarise(min.weight=min(weights),
                max.weight=max(weights),
                mean.weight=mean(weights),
                sum.weights=sum(weights),
                n=n(),
                max.match.ratio=max.weight/min.weight)
    
      treat min.weight max.weight mean.weight sum.weights     n max.match.ratio
    1     0      0.605       4.24           1         112   112               7
    2     1      1           1              1         185   185               1
    

    要查看权重分布,我们可以这样做:

    match.data(m.out1) %>% 
      group_by(treat, weights) %>% 
      tally %>% 
      group_by(treat) %>% 
      mutate(weight.ratio = weights/min(weights))
    
      treat weights     n weight.ratio
    1     0   0.605    74            1
    2     0   1.21     19            2
    3     0   1.82     10            3
    4     0   2.42      6            4
    5     0   3.63      2            6
    6     0   4.24      1            7
    7     1   1       185            1
    

    the MatchIt vignette 末尾有一个常见问题解答。第 5.3 项,“权重到底是如何创建的?”注意到“控制组的权重被缩放到与唯一匹配控制的数量相加 单位。”

    【讨论】:

      猜你喜欢
      • 2021-02-20
      • 2015-09-25
      • 2020-04-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多