I would like to get 95% confidence intervals for the regression coefficients of a quantile regression. You can calculate quantile regressions using the rq
function of the quantreg
package in R (compared to an OLS model):
library(quantreg)
LM<-lm(mpg~disp, data = mtcars)
QR<-rq(mpg~disp, data = mtcars, tau=0.5)
I am able to get 95% confidence intervals for the linear model using the confint function:
confint(LM)
When I use quantile regression I understand that the following code produces bootstrapped standard errors:
summary.rq(QR,se="boot")
But actually I would like something like 95% confidence intervals. That is, something to interprete like: "with a probability of 95%, the interval [...] includes the true coefficient". When I calculate standard errors using summary.lm() I would just multiply SE*1.96 and get similar results as from confint(). But this is not possible using bootstrapped standard errors. So my question is how get 95% confidence intervals for quantile regression coefficients?
You can use the
boot.rq
function directly to bootstrap the coefficients:You may want to use the boot package to compute intervals other than the percentile interval.
You could also simply retrieve the vcov from the object, setting
covariance=TRUE
. This amounts to using boostrapped standard errors in your CI:But yes, the better way to do this is to use a studentized bootstrap.