3
votes

I have discovered some heteroscedasticity in my model that I would like to compensate for with more robust standard errors. I have tried to use the Huber-White robust standard errors from the merDeriv package in R but I beleive these only work for a GLMM with a binomial distribution. Is there a way I could achieve the same thing for a Negative Binomial distribition?

Model:

library(lme4)
model <- glmer.nb(Jobs ~ 1 + Month + Year + (1|Region), data = df)

Huber-White robust standard errors:

library(merDeriv)
bread.glmerMod(model)

Error:

Error in vcov.lmerMod(object, full = full) : estfun.lmerMod() only works for lmer() models.

Thank you for any help!

2

2 Answers

3
votes

This looks like a bug in the package, as far as I can tell (the bread.glmerMod function was calling estfun.lmerMod rather than estfun.glmerMod; there's a broader question here about the design of the generic functions, but never mind ...)

You should be able to install a fixed version from my fork via remotes::install_github("bbolker/merDeriv"), then reload the package and try again.

Alternately, download the tarball, change vcov.lmerMod to vcov.glmerMod in the last line of R/bread.glmerMod.R, and re-install the package ...

0
votes

Try something like this:

library(lme4)
model <- glmer.nb(Jobs ~ 1 + Month + Year + (1|Region), data = df)

cov <- vcovHC(model, type = "HC1", sandwich = T)
se <- sqrt(diag(cov_m1))

(Can't confirm if it works since this there isn't a reproducible example)