This is an extension from this question about 95% confidence intervals for quantile regression using rquant
:
Calculating 95% confidence intervals in quantile regression in R using rq function
Here, the goal is to determine 95% confidence intervals for quantile regression for a polynomial fit.
Data:
x<-1:50
y<-c(x[1:50]+rnorm(50,0,5))^2
Attempt using the approach in the aforementioned question:
QR.b <- boot.rq(cbind(1,x,x^2),y,tau=0.5, R=1000)
t(apply(QR.b, 2, quantile, c(0.025,0.975)))
2.5% 97.5%
[1,] -14.9880661 126.906083
[2,] -20.5603779 5.424308
[3,] 0.8608203 1.516513
But this of course determines the 95% CI for each coefficient independently, and would appear to overestimates the interval (see image below).
I had another idea for an approach simply determining the coefficients from a bootstrap sample of the data (i.e. rq(y~x+I(x^2))
on thousands of samples of y and x), but wanted to see if there is something build it to the package.