How to do a partial matching in R

46 views Asked by At

Dataset : bpp

Matching variable: Group 0:No Ace inhibitor. 1: Ace Inhibitor Group= 1 - bpp$gr

Propensity Scores: dbp, n_bpclasses, play with delta.

Exact: month, sex

Partial: sbp (3 pt), age(2 yr).

(1) Produce a matching.

(2) Compare the matching to Matchit

library(MatchIt)

Version 1

propensity_model <- glm(Group ~ dbp + n_bpclasses, data = bpp, family = binomial())
bpp$propensity <- predict(propensity_model, type = "response")


m.out <- matchit(Group ~ dbp + n_bpclasses, 
                 data = bpp, 
                 method = "nearest",
                 exact =  "sex",
                 caliper = 0.05, 
                 # This is for the propensity score
                 distance = bpp$propensity)

summary(m.out)

Version 2

Matching based on propensity scores, exact for month and sex, and partial for sbp and age

match_out <- matchit(Group ~ dbp + n_bpclasses + sex + sbp + age, 
                     data = bpp, 
                     method = "nearest", 
                     distance = bpp$propensity,
                     exact =  "sex",
                     caliper = 0.2)

summary(match_out)

Version 3

User-supplied propensity scores

bpp['Group'] = 1 - bpp$gr
bpp$pscore <- predict(glm(Group ~ dbp + n_bpclasses, data=bpp, family=binomial()), type="response")

# Create distance matrix
distance <- Matching::GenMatch(Tr=bpp$Group, X=bpp$pscore, M=1,
                               exact = bpp$sex,
                               partial = list(sbp=3, age=2))

matched_genmatch <- Match(Y=NULL, Tr=bpp$Group, X=bpp$pscore, Weight.matrix=distance)
matched_data_genmatch <- bpp[unlist(matched_genmatch[c("index.treated", "index.control")]), ]

I guess I tried so many versions, but none of them could do the partial matching by filtering the matching process.

Anyone could provide some sort of solutions to this issue? I really appreciate it!!!

0

There are 0 answers