r - Pooling sandwich variance estimator over multiply imputed datasets -
i running poisson regression on multiply imputed data predict common binary outcome. after running mice
, have obtained stacked data frame comprising raw data , 5 imputed datasets. here toy example:
df <- mice::nhanes imp <- mice(df) #impute data com <- complete(imp, "long", true) #creates data frame
i want to:
- run regression on each imputed dataset
- calculate robust standard errors using sandwich variance estimator
- combine / pool results of both analyses
i can run regression on mids
object using with
, pool
commands:
fit.pois.mids <- with(imp, glm(hyp ~ age + bmi + chl, family = poisson)) summary(pool(fit.pois.mids))
i can run regression on each of imputed datasets before combining them:
imp.df <- split(com, com$.imp); names(imp.df) <- c("raw", "imp1", "imp2", "imp3", "imp4", "imp5") #creates list of data frames representing each imputed dataset fit.pois <- lapply(imp.df, function(x) { fit <- glm(hyp ~ age + bmi + chl, data = x, family = poisson) fit }) summary(micombine(fit.pois))
similarly, can calculate standard errors each imputed dataset:
sand <- lapply(fit.pois, function(x) { se <- coeftest(x, vcov = sandwich) se })
unfortunately, micombine
not seem return p-values. post suggests using zelig
, matter, may use mice
. further not appear possible combine estimates of standard errors:
summary(micombine(sand.df)) error in usemethod("vcov") : no applicable method 'vcov' applied object of class "coeftest"
for sake of simplicity, seems mice
better option pooling results of regression; however, wondering how go updating (i.e., pooling , combining) standard errors. ways addressed?
Comments
Post a Comment