IQSS / Zelig

A statistical framework that serves as a common interface to a large range of models
http://zeligproject.org
109 stars 43 forks source link

ATT with Matchit Weights #311

Closed christophergandrud closed 6 years ago

christophergandrud commented 6 years ago

From Eric Meng via email:

"do I have to specify "weights" in the Zelig command on purpose if it is run right after MatchIt, because it is said that "Weights that are creating using the matching mechanisms in the MatchIt package will be automatically employed in Zelig analyses if the output object from MatchIt is passed to Zelig as the data argument." in http://docs.zeligproject.org/articles/weights.html?"

with weights specified:

z.out1 <- zelig(mt90~age+sex_m+zcrenal+zimmunesn+antic+ncci+popdcnt+
                        zhtn+zdmta+bb+acei+antip, 
                       data = match.data(m.out1), model = "logit", 
                       weights =weights, cite = FALSE)

Noninteger weights were set, but the model in Zelig is only able to use integer valued weights.

A bootstrapped version of the dataset was constructed using the weights as sample probabilities.

z.out1 <- ATT(z.out1, treatment = "stat")
zatt <- get_qi(z.out1, qi = "ATT", xvalue = "TE")
summary(zatt)

##     Min.   1st Qu.    Median      Mean   3rd Qu.      Max. 
## -0.031325 -0.001817  0.006227  0.006206  0.014310  0.046401 

without weights specified:

z.out1 <- zelig(mt90~age+sex_m+zcrenal+zimmunesn+antic+ncci+popdcnt+zhtn+
                         zdmta+bb+acei+antip, data = match.data(m.out1), 
                         model = "logit", cite = FALSE)

z.out1 <- ATT(z.out1, treatment = "stat")
zatt <- get_qi(z.out1, qi = "ATT", xvalue = "TE")

summary(zatt)

## Min.   1st Qu.    Median      Mean   3rd Qu.      Max. 
## -0.049669 -0.020448 -0.011659 -0.011900 -0.003951  0.023122 
christophergandrud commented 6 years ago

I believe the issue is the use of the match.data call within the zelig call.

This is unnecessary and, because it returns a data frame rather than a matchit object removes zelig's ability to know about the weights.

So, if you don't use match.data everything should work as normal.

I'm going to close this issue, but feel free to reopen if it doesn't solve your problem.