Is it possible to have confint use the robust vcov obtained by vcovHC (from the sandwich package) after fitting a model?
Nope, you cannot use the function confint directly with the robust vcov. But it's pretty straight-forward to do this by hand.
x <- sin(1:100)
y <- 1 + x + rnorm(100)
## model fit and HC3 covariance
fm <- lm(y ~ x)
Cov <- vcovHC(fm)
tt <-qt(c(0.025,0.975),summary(fm)$df[2])
se <- sqrt(diag(Cov))
ci <-coef(fm) + se %o% tt
Otherwise, your can adapt the confint.default()
function to your own needs :
confint.robust <- function (object, parm, level = 0.95, ...)
{
cf <- coef(object)
pnames <- names(cf)
if (missing(parm))
parm <- pnames
else if (is.numeric(parm))
parm <- pnames[parm]
a <- (1 - level)/2
a <- c(a, 1 - a)
pct <- stats:::format.perc(a, 3)
fac <- qnorm(a)
ci <- array(NA, dim = c(length(parm), 2L), dimnames = list(parm,
pct))
ses <- sqrt(diag(sandwich::vcovHC(object)))[parm]
ci[] <- cf[parm] + ses %o% fac
ci
}
As Brandon already suggested, you'd get more chance of a quick answer if you ask these things at stats.stackexchange.com
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With