0

I am able to successfully run a PSM model using Matchit, but I am struggling to output the actual paired matches. My code is here ...

model_raw <- matchit(source ~ last_payment_amount + 
     balance_at_purchase + days_since_chgoff, 
     data=model1_file, method="nearest", distance="glm", 
     caliper=.50)

summaryfileraw <- summary(model_raw)
mraw_data <- match.data(model_raw)

head(model_raw$match.matrix)
model1_file[1, ]
model1_file[3128, ]

matrixraw <- model_raw$match.matrix

I can see, for example that obs "1" from the Control matched "3218" from the Treatment. But, in the context of the actual data file, these values do not mean anything and I cannot seem to export these values from the match.matrix in a way that retains the original data. I do have an account number (cleverly called "account number") in the original data. Is there a way to export the output such that I can see the "account number" for obs "1" and obs "3128"?

I have tried the code below with no joy:

head(model_raw$match.matrix)
model1_file[1, ]
model1_file[3128, ]
print(model_raw$match.matrix)
matrixraw <- model_raw$match.matrix
write.csv(matrixraw, file="C:\\PSM TESTING\\matrixraw.csv")  
kjetil b halvorsen
  • 1,206
  • 2
  • 18
  • 28
  • 2
    Please provide enough code so others can better understand or reproduce the problem. – Community Feb 27 '23 at 21:48
  • 2
    It's easier to help you if you include a simple [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) with sample input and desired output that can be used to test and verify possible solutions. – MrFlick Feb 27 '23 at 21:54
  • Does `match.data()` not do what you want? – Noah Feb 27 '23 at 23:19

0 Answers0