使用 R 的“CBPS”包后如何访问匹配的数据集?

How to access matched dataset after using `CBPS` package of R?

我正在使用 CBPS R 包对数据集与两级治疗组进行倾向得分匹配。
这是我写的代码:

fit <- CBPS(formula=formu1, data = data2, ATT = TRUE, twostep = FALSE, standardize = TRUE)
    
rr.att.CBPS <- Match(Y=Y, Tr=Tr, X=fitted(fit), M=1, ties=FALSE, replace=FALSE, estimand='ATT')

但是,如何访问匹配的数据集进行分析?

我建议您改用 MatchIt 包。
想象一个名为 'dataset' 的数据集,其中包含一个二元处理组 (T) 和一些其他协变量 (V1,V2,V3) 和一个目标变量 (p)。

install.packages("MatchIt")   #if not installed before
library("MatchIt")     #importing MatchIt

# Formula for matching(include other covariates which treatment groups will be matched based on them, eg. V1 & V2)
formula <- "T ~ V1+V2"
formula <- as.formula(formula)    #making formula format

#implementing matching process with nearest neighbour method with 2:1 ratio by logistic regression
matched_data <- matchit(formula, method = "nearest", ratio = 2, data = dataset, link = "logit")

# assigning matched data to a variable which then can be used for further analysis such as regression
final_matched <- match.data(mached_data)


# Absolute standardized mean difference plot of variables used to match for assessment of balance before and after matching
plot(summary(matched_data))