I would like to use propensity scores that I developed from a multilevel logistic model as the distance measure for matching using the MatchIt package in R. The documentation for MatchIt says that I can use my own distance measure with the distance option, but how do I specify it? I have tried:

m.out.M1 <- matchit(data=retention, method="nearest", m.order="random", 
distance= M1_PS, caliper=.2)

M1_PS is the variable name of my distance measure that is in the dataset, but I get error message, "M1_PS not found". I did not include a formula statement in my code because I'm assuming that I do not need one if I am using my own distance measure.

  • $\begingroup$ You need a formula to tell MatchIt what the treatment variable is. It doesn't matter what is on the right side of the formula. $\endgroup$ – Noah Apr 10 '18 at 0:59

I found an answer to a similar question on the R MatchIt listserv. It says:

"It will look something like

m.out <- matchit(treat ~ x1 + x2, data=dataset, 

The treat ~ x1 + x2 formula is then used just to tell matchit what the treatment variable is and what the covariates to check balance on are."


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.