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$
4
  • 2
    $\begingroup$ Thanks. In that case, what does Stata's vce(robust) do? It definitely changes standard errors. $\endgroup$
    – user
    Commented Nov 20, 2020 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$ Commented Nov 22, 2020 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$ Commented Nov 24, 2020 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$
    – user
    Commented Nov 24, 2020 at 9:50

1 Answer 1

3
$\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.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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