简体   繁体   English

在 R 中使用 Matchit 以 1:5 的比例仅获取完全匹配的案例

[英]Get only the fully matched cases using Matchit in R using 1:5 ratio

I have matched my two groups with 1:5 ratio and noticed that my two resulting groups do not have a 1:5 ratio, similar to this question posted here:我以 1:5 的比例匹配了我的两个组,并注意到我的两个结果组没有 1:5 的比例,类似于此处发布的这个问题:

3:1 matching with MatchIt in R. 在 R 中与 MatchIt 进行 3:1 匹配。 The number of matched control is not equal to 3 times the number of cases 匹配对照数不等于病例数的3倍

I have performed a match like this:我进行了这样的比赛:

    match_out <- matchit(as.formula(paste0("treat~",covar)),
                      data = data, replace = FALSE,
                      caliper = .2, ratio = 5, method = "nearest") 

And my ouput looks like this:我的输出如下所示:

> match_out 

Call: 
matchit(formula = as.formula(paste0("treat~", covar)), data = data, 
    method = "nearest", replace = FALSE, caliper = 0.2, ratio = 5)

Sample sizes:
          Control Treated
All          7594      13
Matched        42      10
Unmatched    7552       3
Discarded       0       0


> match_out$match.matrix
     1      2      3      4      5     
14   "3891" NA     NA     NA     NA    
300  "5160" "2282" "2634" "6349" NA    
578  "5343" "5486" "4433" "2026" "249" 
997  "1121" "3928" "6464" "5015" "1863"
1534 NA     NA     NA     NA     NA    
1787 "7517" "7053" "5187" "4157" "919" 
4016 "525"  "5514" NA     NA     NA    
4082 "5548" "2951" "7282" "3378" "2642"
4894 "1009" "6386" "946"  "1819" "1727"
5812 NA     NA     NA     NA     NA    
5954 "7298" "6898" "1503" "7004" "7110"
6825 NA     NA     NA     NA     NA    
7389 "4286" "3044" "985"  "1471" "3591"

As I understand it correctly, my output now contains all the cases where a match of at least one has occured.据我正确理解,我的 output 现在包含所有发生至少一个匹配的情况。

Now I would like to know, if there an (easy) way to get only those that have a full match of 5 Controls per 1 Treated (which would be 7 in my case).现在我想知道,是否有一种(简单的)方法可以只获得那些完全匹配每 1 个处理的 5 个控件(在我的情况下为 7 个)的控件。

To restrict to just the units who have exactly 5 matches, you can just run na.omit() on the match.matrix output.要限制只有恰好有 5 个匹配的单元,您可以在match.matrix output 上运行na.omit() That will produce a matrix with just the treated and control units who have all 5 matches.这将生成一个矩阵,其中仅包含所有 5 个匹配项的处理单元和控制单元。 From there you can subset the match.data() output to get just those you need, eg,从那里您可以将match.data() output 子集化以获得您需要的内容,例如,

m_data <- match.data(match_out, data = data)

mm <- na.omit(match_out$match.matrix)

m_data <- m_data[rownames(m_data) %in% rownames(mm) |
                   rownames(m_data) %in% mm,]

You can then run your effect estimation in m_data .然后,您可以在m_data中运行效果估计。 Note that what you are proposing is not a very good idea;请注意,您提出的建议不是一个好主意; you are needlessly discarding units with no apparent benefit.您不必要地丢弃没有明显好处的单位。

Just to answer my own question: It seems like you can force a full 1:5 match by adding: method = "optimal" to the function.只是为了回答我自己的问题:您似乎可以通过在 function 中添加: method = "optimal"来强制进行完整的 1:5 匹配。 Read more here: https://cran.r-project.org/web/packages/MatchIt/vignettes/matching-methods.html#optimal-pair-matching-method-optimal在此处阅读更多信息: https://cran.r-project.org/web/packages/MatchIt/vignettes/matching-methods.html#optimal-pair-matching-method-optimal

This however will decrease the success of matching.然而,这会降低匹配的成功率。 Would anyone know a way of selecting only those 1:5 cases from the original output?有人知道从原始 output 中仅选择那些 1:5 案例的方法吗?

EDIT: As Noah pointed out, the 1:5 match can be forced, but this will ignore the caliper.编辑:正如诺亚指出的那样,可以强制进行 1:5 比赛,但这会忽略卡尺。 See the documentation here: https://rdrr.io/cran/MatchIt/man/method_optimal.html I thought it was a bit hidden, but you can see under the header "Arguments" it says: "The arguments replace, caliper, and m.order are ignored with a warning." See the documentation here: https://rdrr.io/cran/MatchIt/man/method_optimal.html I thought it was a bit hidden, but you can see under the header "Arguments" it says: "The arguments replace, caliper,和 m.order 被忽略并发出警告。”

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 R MatchIt:使用 ratio 和 caliper 参数似乎强制 replace=T - R MatchIt: Using ratio and caliper arguments seems to force replace=T R:使用 MatchIt 进行倾向得分匹配。 如何使用replace = TRUE找到匹配的观察数? - R: Propensity Score Matching using MatchIt. How to find the number of matched observations with replace = TRUE? R中与MatchIt进行3:1匹配。匹配控件的数量不等于案例数量的3倍 - 3:1 matching with MatchIt in R. The number of matched control is not equal to 3 times the number of cases 使用 CEM 和 MatchIt R 包的不同结果 - Differing results using CEM and MatchIt R packages R:使用MatchIt 1:n倾向得分比赛 - R: 1:n propensity score match using MatchIt 在 PSM(R 的 Matchit 包)中使用卡尺会改变匹配并使平衡变得更糟,即使匹配处理的数量保持不变? - Using a caliper in PSM (R's Matchit package) changed matching and made balance worse, even though number of matched treatment remained the same? 使用 grepl 在 R 中获取匹配的字符串 - Get matched String in R using grepl 如何使用 MatchIt 在 R 中准备倾向得分匹配的变量? - How to prepare the variables for propensity score matching in R using MatchIt? 为什么 PSM 结果不同使用 R 中的 Matching 和 Matchit - Why the PSM results differ using Matching and Matchit in R Matchit R - 如何运行 1 CONTROL: 2 TREATED 单元的比率? - Matchit R - how to run ratio of 1 CONTROL: 2 TREATED units?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM