ngreifer / WeightIt

WeightIt: an R package for propensity score weighting
https://ngreifer.github.io/WeightIt/
102 stars 12 forks source link

Does `WeightIt`package support outcome regression of lmer() #67

Closed liaoqijia closed 3 weeks ago

liaoqijia commented 1 month ago

Hi, thanks for developing the R package. I have a question of whether I can fit the outcome regression with lmer() by using the weight obtained from the following code: W <- weightit(Ac ~ X1 + X2 + X3 + X4 + X5 + X6 + X7 + X8 + X9, data = d, moments = 2, int = TRUE, method = "ebal") W

Best, Qijia

ngreifer commented 1 month ago

You might be able to include the weights in a lmer() model, but you can't calculate correct standard errors. The standard errors that come from the model are completely invalid. In most cases, though, you don't need to use a mixed model to estimate treatment effects after weighting. If your goal is to estimate a treatment effect, you can just compute a weighted difference in means (e.g., using lm_weightit()) and use a cluster-robust SE if your units are nested in clusters. If this is for a longitudinal analysis, you can try using GEE. But there are very few cases where a mixed model is required. If you want correct SEs from a mixed model, you can try doing a cluster bootstrap.