【问题标题】:When both mahalanobis and exact match is needed. How to combine them both in MatchIt当需要 mahalanobis 和完全匹配时。如何在 MatchIt 中将它们结合起来
【发布时间】:2021-12-05 14:08:11
【问题描述】:

我正在使用 MatchIt 包来查找最近的邻居。我遇到的问题是,我希望 R 仅在棕色债券池中匹配(当 dummy=1 时),它们与被踩踏的公司来自同一国家和行业,并且在同一年。换句话说,我能理解的部分完全匹配和一些 Mahalonbis,我的问题是当距离 = mahalanobis 时,我不知道如何将它们结合在 matchit 函数中。

样本数据:

    Brown <- c("1","1","0","1","0","1","0","0")
    SIC <- c(10, 11, 67, 20, 31, 12, 31, 31)
    year <- c("2013","2013","2012","2014","2013","2012","2011","2013")
    size <- c(2000,1000,1200,3100,3131,1233,1920,910)
    tobinsq <- c(13,23,11,1,31,131,321,111)
    country <- c("US","CA","NO","US","US","ES","CA","US")

    dframe <- data.frame(Brown,year,SIC,country,tobinsq)

# Mahalanobis distance matching - no PS estimated

    matchman <- matchit(treat ~ size + tobinsq, data = dframe,
    distance = "mahalanobis")

如何在此处合并BrownyearSICcountry(它们需要与处理过的完全匹配)?

希望有人可以帮助我!

【问题讨论】:

    标签: r matching


    【解决方案1】:

    使用exact 参数。您的代码如下所示:

    matchman <- matchit(treat ~ size + tobinsq, data = frame,
                        distance = "mahalanobis",
                        exact = ~Brown + year + SIC + country)
    

    有关详细信息,请参阅 help("matchit")help("method_nearest")vignette("estimating-effects", package = "MatchIt")。这是一个有据可查的功能。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-01-04
      • 1970-01-01
      • 2019-12-05
      • 2015-05-22
      • 2018-04-13
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多