【问题标题】:Subclassification with Mahalanobis distance nearest neighbor matching in RR中马氏距离最近邻匹配的子分类
【发布时间】:2020-07-05 06:37:48
【问题描述】:

我正在使用 MatchIt 包来实现与马氏距离的最近邻匹配。在匹配阶段之后,我如何让它报告哪个对照观察与每个治疗观察匹配?

以下代码不起作用并抛出警告“没有纯马氏距离的子分类。”

library("MatchIt")

data("lalonde")

lalonde_matchit_nn <-
  matchit(
    treat ~ age + educ + black + hispan + nodegree + married + re74 + re75,
    baseline.group = 1,
    data = lalonde,
    method = "nearest",
    distance = "mahalanobis",
    subclass = T
  )

再次,我要寻找的是输出具有每对处理和控制的 ID,就像使用其他匹配方法(例如,“exact”或“cem”)报告的子类一样。

【问题讨论】:

  • 警告是因为你有method = "mahalanobis"subclass = T,但是你不能把它们放在一起。您可以选择子分类(倾向得分)或马氏距离匹配。
  • @Noah 谢谢,是的,我意识到了。对于最近邻匹配,不跟踪匹配组(这是子类正在做的事情)似乎是一个奇怪的设计选择。我意识到,与其他匹配方法不同,它是 1:1 匹配,因此不需要,例如,在组内加权。但是有一个带有子类 ID 的列对于其他目的仍然有用,并且在我的应用程序中是必需的。
  • 你看到我的回答here 解决了这个问题吗?

标签: r mahalanobis


【解决方案1】:

在这种情况下,您正在寻找输出的属性:输出为lalonde_matchit_nn,属性为nnmatch.matrix

smry<-lalonde_matchit_nn$nn #A basic summary table of matched data (e.g., the number of matched units)

#represent the names of the treatment units, which
#come from the data frame specified in data. Each column stores the name(s)
#of the control unit(s) matched to the treatment unit of that row. F
matchedPool<-lalonde_matchit_nn$match.matrix

现在,如果您从上面的代码中查看 smry 和匹配池:

smry
          Control Treated
All           429     185
Matched       185     185
Unmatched     244       0
Discarded       0       0

head(matchedPool)

     1        
NSW1 "PSID375"
NSW2 "PSID341"
NSW3 "PSID361"
NSW4 "PSID345"
NSW5 "PSID172"
NSW6 "PSID237"

smry 告诉每个类型的人口,匹配池会根据您的最佳标准为您提供匹配的 ID,在本例中为 Mahanlobis 距离,但是警告消息 Warning message: No subclassification with pure Mahalanobis distance 告诉您,对于此方法,其他最佳参数可能是更好的选择。

有关更多详细信息,最好参考包装文档, https://cran.r-project.org/web/packages/MatchIt/MatchIt.pdf

【讨论】:

    猜你喜欢
    • 2020-11-24
    • 2013-09-10
    • 1970-01-01
    • 2011-06-18
    • 2016-04-14
    • 1970-01-01
    • 2016-04-21
    • 1970-01-01
    相关资源
    最近更新 更多