
[英]In `data.table` within R, is there a fast way to combine tables together?
[英]Is there a way to combine multiple MatchIt objects together in R
我有一个数据集,我正在对其进行匹配,该数据集是具有重叠成员资格的重复横截面:
会员ID | 治疗 | 学习月 | 年龄 | 性别 | 风险评分 | 慢性阻塞性肺病 | 瑞士法郎 | 糖尿病 | 复杂提供者FLG |
---|---|---|---|---|---|---|---|---|---|
123 | 1 | 1 | 54 | 米 | 1.45 | 0 | 1 | 1 | 0 |
201 | 0 | 1 | 55 | 米 | 1.54 | 0 | 1 | 1 | 0 |
205 | 0 | 1 | 85 | 米 | .8 | 1 | 0 | 0 | 0 |
155 | 1 | 2 | 56 | 米 | 1.58 | 0 | 1 | 1 | 0 |
201 | 0 | 2 | 55 | 米 | 1.54 | 0 | 1 | 1 | 0 |
208 | 0 | 2 | 58 | 米 | 1.68 | 0 | 0 | 1 | 0 |
注意成员 201 在第一个月和第二个月的横截面。 因此,当我在一个 StudyMonth 匹配时,我需要从潜在匹配池中删除与该截面匹配的个体,以用于未来的截面。在上面的玩具示例中,即使 201 是第 1 个月的 123 和第 1 个月的 155 的最佳控制第 2 个月,我不想让他在控制池中两次。
做一个 for 循环并重新运行匹配非常简单,消除先前选择的个体,然后将每个循环的结果绑定到一个最终的治疗/对照组中,如下所示:
for (MatchMonth in 0:11){
WorkingMatchedCohort <- matchit(Treatment ~ Age + Sex + RiskScore +
CHF + COPD + Diabetes + Depression + ComplexProviderFLG,
data= filter(WorkingSet,(Treatment==0 | Treatment==1) & StudyMonth==MatchMonth))
if(exists("unionedmatches")) {
unionedmatches<-bind_rows(unionedmatches,match.data(WorkingMatchedCohort))
}else{
unionedmatches<-match.data(WorkingMatchedCohort)
}
##Flag members so that they're not reused
WorkingSet$Treatment[WorkingSet$Treatment==0 & WorkingSet$MemberID %in% unionedmatches$MemberID] <-2
}
这给了我使用match.data
在unionedmatches
中的组合结果。 但是我将如何 go 关于组合实际的 MatchIt 对象WorkingMatchedCohort
以便我可以使用内置的 MatchIt 工具来绘制拟合优度?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.