azadag
4/22/2016 - 4:53 PM

propensity score match helper code from 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")