Problems with distance matrix - R propensity score matching

89 views Asked by At

I have a cohort with about 10 covariates (e.g age, sex, region, index_agent, etc) for which I am trying to match cases to controls in a 1:3 ratio. An additional criteria I have for this match is that my variable called match_time must be greater for the control (bleed == 0) than it is for the case (bleed == 1). I am using the MatchIt package.

Based on the answer to a previous question on here, I created a distance matrix and marked the forbidden matches forbidden matches Inf with this code after using a glm to estimate propensity scores.

# Create distance matrix of ps, with treated units
# on rows and control units on columns
ps_dist <- MatchIt::euclidean_dist(bleed ~ ps, data = prematch)

# Set to `Inf` any forbidden matches
case_times <- prematch$match_time[prematch$bleed == 1]
control_times <- prematch$match_time[prematch$bleed == 0]
ps_dist[outer(case_times, control_times, ">=")] <- Inf

I then used this distance matrix in the matchit function and ran the match. I got 3 matches per case, but then realized that a decent number of my cases were still being matched controls whose match_time was less than their corresponding case.

I manually checked a few combinations on my distance matrix and it seems like there the correct combinations have the Inf value in their cell, so I am not sure what's going on.

I tried decreasing my caliper and my ratio as well to see if that would stop me from getting matches that should be forbidden, but I am still having the same problem.

Any help or thoughts on what my problem might be are appreciated!

Thank you!

0

There are 0 answers