Saving variable not used in matching in matching output

Hi,

I'm trying to use GenMatch to find the control units that best balances covariates.

As I need to link the matched sample to some other data afterwards, I need to keep the identifying variable (bvd_id). This variable, however, is not used for the matching - so when saving the matching output bvd_id is not included.

I tried to simply bind bvd_id from AT, but obviously this didn't work as the bvd_id's where assigned in the order they were in "AT" and not to the correct firms.

How should I go about this? Any suggestions would be very much appreciated!

Here's my code:

AT <- read_dta("AT.dta")
zsAT <- (AT$ETS)
random_numbers <- runif(nrow(AT))
AT <- cbind(AT, random_numbers)
YAT <- (AT$random_numbers)
XsAT <- data.frame(AT$bvd_sector_num, AT$last_avail_year, AT$b_pat9903, AT$incorporation_year, AT$revenue_last, AT$green_pat9903)
balance_matrix_simpleAT <- XsAT
genAT <- GenMatch(Tr=zsAT, X=XsAT, BalanceMatrix=balance_matrix_simpleAT, pop.size=500, replace=TRUE, caliper=c(100,100,100,100,0.1,0.1), fit.func="qqmean.mean")
exactAT <- rep(FALSE, length(colnames(XsAT)))
exactAT[grep("b_pat9903", colnames(XsAT))] <- TRUE 
exactAT[grep("bvd_sector_num", colnames(XsAT))] <- TRUE
exactAT[grep("last_avail_year", colnames(XsAT))] <- any(abs(XsAT$last_avail_year - AT$last_avail_year) <= 2)
mAT <- Match(Y=YAT, Tr=zsAT, X=XsAT, Weight.matrix=genAT, exact = exactAT, version='fast')
mAT$index.treated <- as.numeric(rownames(AT[mAT$index.treated,]))
mAT$index.control <- as.numeric(rownames(AT[mAT$index.control,]))
mAT$index.dropped <- as.numeric(rownames(AT[mAT$index.dropped,]))
rm("balance_matrix_simpleAT","exactAT","XsAT","zsAT","YAT")
m_AT_simple <- as.data.frame(mAT$mdata)
write.dta(m_AT_simple, "/Users/lorenselvangthomassen/Desktop/Politik√ėkonomi/6. Semester/Bachelor/ETS/Data/Eget/PC/R/m_AT_simple.dta")

This topic was automatically closed 42 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.