文章预览
matchit包官网核心内容 示例教程里面的内容很多比较重要,本次仅演示初步的用法 官网教程地址:https://rdrr.io/cran/MatchIt/f/vignettes/MatchIt.Rmd 代码示例 #加载测试数据 data( "lalonde" , package = "cobalt" ) head(lalonde) 测试数据 数据说明:We have our outcome (re78), our treatment (treat), and the covariates for which balance is desired (age, educ, race, married, nodegree, re74, and re75). Using cobalt, we can examine the initial imbalance on the covariates:
可以看到,分组变量treat为分类变量,结果变量re78为连续性变量。 #基线分组混杂因素分布情况 library( "cobalt" ) bal.tab(treat ~ age + educ + race + married + nodegree + re74 + re75, data = lalonde, estimand = "ATT" , thresholds = c(m = .05)) love.plot(treat ~ age + educ + race + married + nodegree + re74 + re75, data = lalonde) 根据SMD为0.05的标准,所有变
………………………………