6
$\begingroup$

I would like to perform a logistic regression by adjusting for propensity score. My question is, do I have to include the outcome (binary in my case) in the propensity score calculation? Otherwise how else can I link the outcome variable to the matched data created? For example if I don't put the outcome variable in function matchit() like in the scripts below

library(MatchIt)
m.out<-matchit(treatment~var1+var2+var3+var4, data = data,method = "nearest", ratio=1)
dataMatched = match.data(m.out)

I will have such a data.frame which doesn't contain outcome. How could I make the link between the outcome variable and this data frame in order to do the final analysis.

 treatment var1 var2 var3 var4 distance weights
1         0    1    1    0    0   0.4135      1
2         0    1    0    1    1   0.5446      1
3         0    0    0    0    0   0.6534      1
4         1    1    1    1    0   0.7343      1


library(Zelig)
z.out = zelig(outcome ~treatment+var1+var2+var3+var4, model = "logit",data = dataMatched )
$\endgroup$
2
  • 4
    $\begingroup$ +1 because this a horrible mistake to make. No, definitely do not use the outcome variable for anything else other than evaluating the treatment. Never condition in post-treatment variables. Otherwise would essentially know the future. :) $\endgroup$
    – usεr11852
    Commented Jun 1, 2020 at 16:56
  • $\begingroup$ after matching with matchit (without the outcome variables), I want to do a test of difference in means to estimate the effect sizes. My problem is the same: How can I combine my mached model with the original dataset for further analysis(test of difference in means). You wrote, the "procedure is a bit more involved". Can you help me? Thanks a lot. Christoph $\endgroup$ Commented Nov 5, 2020 at 15:35

1 Answer 1

7
$\begingroup$

DO NOT include the outcome in the propensity score calculation. To analyze your data after matching, don't use match.data(). Just use your original data set, which hopefully contains the treatment and the outcome, and include the weights in the matchit output object in the outcome model. You can do this as follows:

m.out <- matchit(treatment ~ var1 + var2 + var3 + var4, data = data,
                 method = "nearest", ratio=1)
fit <- glm(outcome ~ treat, data = data, family = binomial,
           weights = m.out$weights)

Observations with weights of zero (indicating that they were not matched) will simply be excluded from the analysis. If you want to do a paired analysis, pair membership is in the subclass component of the matchit output object and you can include it as a fixed or random effect in the outcome regression model to mimic a paired t-test or use it as the clustering variable in a cluster-robust standard error.

$\endgroup$
3
  • $\begingroup$ Hi Noah. I've really learned much from numerous of your answers here. Doing nearest-neighbour matching currently outputs a subclass variable. Has this just been changed since your posted your answer here, or? I want to perform Cox stratified by matched pairs after propensity-score matching (as I understand from the literature that the data have to be treated as paired data). I assume I can just use something like coxph(Surv(time_to, status) ~ exposure + var1 + ... + varN + strata(subclass), data=df)) and that this'll work fine with pool(with()) after using MICE+MatchThem? $\endgroup$
    – ZKA
    Commented Dec 16, 2021 at 23:50
  • $\begingroup$ Yes, this has changed since I posted my answer (because of changes I made to MatchIt). See the documentation for MatchThem::with(). You should not treat the pairs as strata but just account for pairing by treating pair membership as a cluster variable. In coxph(), this would be done with the cluster argument. If you use svcoxph() with MatchThem, cluster membership is automatically incorporated. $\endgroup$
    – Noah
    Commented Dec 17, 2021 at 6:47
  • $\begingroup$ Thanks, that’s perfect. After trying stratification by pairs and getting unreasonably wide CIs, I dug through the literature for a bit and arrived at the robust variance estimate-solution as well, and cluster = subclass in copxh() works beautifully. Thanks once again! $\endgroup$
    – ZKA
    Commented Dec 18, 2021 at 11:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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