问题描述
作为我硕士论文研究的一部分,我已经在 R 中实现了 MatchIt 包。该代码目前以 1:2 的比例匹配一些可持续投资公司与非可持续投资公司。
我需要修改我的代码,以便匹配具有匹配 ID。目前代码运行良好且匹配正确,但我不知道哪些公司与哪些控件配对。
有人可以提出修改意见吗?
我没有包含我的所有代码,因为我认为这太过分了,但匹配步骤的主要内容如下:
matchData <-
rbind(treat_firms_1year_prior,control_firms_year_int_tx)
matchData <- matchData %>%
modify_at(c("country","region","strategy","signatory","eligible_treat_firm"),as.factor) %>%
arrange(investor,dealyear)
matchpanel3 <- MatchIt::matchit(eligible_treat_firm ~ counttotal + dealyear,exact= ~ region + strategy,data = matchData,distance = "mahalanobis",ratio = k+1)
非常欢迎任何建议!
罗里
解决方法
匹配 ID 存储在 subclass
对象的 matchit
组件中或存储在 subclass
输出的 match.data()
列中。您不必自己创建这些。