每次火柴包装都会产生不同的结果吗?

时间:2020-11-08 15:17:50

标签: r

每次使用Matchit软件包时,条件逻辑回归的结果都不同。

对吗?

df.final = as.data.frame(na.omit(df))
opt.psm.out4 = matchit(treat~ gr_age+sex+dx_htn+dx_dm+dx_ckd+gr_cci, method = "nearest", data = df.final, ratio=3)
opt.data4 = match.data(opt.psm.out4)

match.matrix<-opt.psm.out4[["match.matrix"]] 
#Getting strata from nearest neighbor matching 
opt.data4$subclass <- vapply(rownames(opt.data4), function(x) {   
  out <- which(rownames(match.matrix) == x | apply(match.matrix, 1, function(y) x %in% y))
  if (length(out) == 0) out <- NA_integer_   
  out 
}, integer(1L))  
cbind(table(opt.data4$subclass ))

1 个答案:

答案 0 :(得分:0)

使用matchit()时存在随机性,并且数据中存在联系。当同一治疗组的两个单位的倾向得分相同时,就会发生平局。在4..0.0之前的MatchIt版本中,领带的成员是随机抽样的,因此每次可能会得到不同的结果。

MatchIt 4.0.0(现在位于CRAN中)中,除非重新组合数据集或选择随机匹配顺序,否则每次都应获得相同的结果。通过根据数据顺序选择单位来解决关系。这增加了一定程度的任意性,但确保了使用完全相同的数据集时结果可复制。