2
$\begingroup$

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.

$\endgroup$
  • 2
    $\begingroup$ Thanks. In that case, what does Stata's vce(robust) do? It definitely changes standard errors. $\endgroup$ – Chr Nov 20 at 19:17
  • 1
    $\begingroup$ @BigBendRegion: do you want to post your comment(s) as an answer? Better to have a short answer than no answer at all. Anyone who has a better answer can post it. $\endgroup$ – kjetil b halvorsen Nov 22 at 15:22
  • 1
    $\begingroup$ @Chr, my guess would have been option option "nid", see also stata.com/features/overview/quantile-regression. Have you tried if it replicates the Stata results? $\endgroup$ – Christoph Hanck Nov 24 at 8:02
  • 1
    $\begingroup$ I did indeed compare the standard errors in R with those in Stata using an example. R's non-adjusted standard errors were the same as the ones Stata produces with vce(robust). However, they were different from standard errors that Stata generates without the vce(robust) option. $\endgroup$ – Chr Nov 24 at 9:50
1
$\begingroup$

There is no assumption of homoscedasticity in the quantile regression model. You need to assume independence, and you need assume linearity (or correct functional specification) of the quantile (median in your case) function, but you do not assume any particular distribution, and you do not assume homoscedasticity.

I can't say what stata might be doing here, but it does not seem right to me for this application. Whatever standard error methods are used (e.g., bootstrapping rows) should account for heteroscedasticity automatically.

| cite | improve this answer | |
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.