Does anyone know how to compute heteroskedasticity-robust standard errors in median regressions in R?
Assume the following example:
require("quantreg")
df <- iris
rq(Sepal.Length ~ Sepal.Width + Petal.Length, data = df)
I know that summary.rq
offers multiple standard error options. But I do not know which option is the right one in my case. I would like to use the standard errors that Stata employs:
sysuse auto.dta
qreg price mpg trunk, vce(robust)
When running linear regressions in R, I correct standard errors with coeftest
:
# Load packages
packs <- list("quantreg", "lmtest", "sandwich")
lapply(packs, require, character.only = T)
df <- iris
rq_outp <- lm(Sepal.Length ~ Sepal.Width + Petal.Length, data = df)
coeftest(rq_outp, vcov = vcovHC(rq_outp, type = "HC1"))
However, coeftest
does apparently not work on rq
objects.
vce(robust)
do? It definitely changes standard errors. $\endgroup$ – Chr Nov 20 '20 at 19:17"nid"
, see also stata.com/features/overview/quantile-regression. Have you tried if it replicates the Stata results? $\endgroup$ – Christoph Hanck Nov 24 '20 at 8:02vce(robust)
. However, they were different from standard errors that Stata generates without thevce(robust)
option. $\endgroup$ – Chr Nov 24 '20 at 9:50