r 倾向得分匹配来自http://stackoverflow.com/questions/23970707/propensity-score-matching-in-matchit-package的助

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了r 倾向得分匹配来自http://stackoverflow.com/questions/23970707/propensity-score-matching-in-matchit-package的助相关的知识,希望对你有一定的参考价值。

#First, after you open the data set but before you run MatchIt, use the following code (data is your data frame and ID is your identifer):

####set rownames to id.
rownames(data) <- data$ID
head(data)
#Second, Run the appropriate matchit syntax into an object, like so:

M.OUT1 <- matchit(Treat ~ X1 + X2, data = data)

#Third run the following code:

mm<-M.OUT1$match.matrix
tx<-as.numeric(row.names(mm))
m<-cbind(tx,as.numeric(mm))
m[1:5,]
View(m)
write_sav(data.frame(m),"MatchedPairs.sav")

以上是关于r 倾向得分匹配来自http://stackoverflow.com/questions/23970707/propensity-score-matching-in-matchit-package的助的主要内容,如果未能解决你的问题,请参考以下文章

倾向得分匹配(PSM)的原理以及应用

PSM的stata实现

因果推断笔记——python 倾向性匹配PSM实现示例

因果推断笔记——python 倾向性匹配PSM实现示例

R中多维度的聚类/匹配

如何用R语言实现倾向评分匹配(Propensity Score Matching)