2

Can anyone suggest a way to construct confidence bands on a particular quantile regression line? I am working with the quantreg package in R.

Thomas
  • 1,071
  • There is no such option available AFAIK, unless you are willing to hack your way to a result. – user2974951 Jan 15 '19 at 13:43
  • You may want to ask this question on stackoverflow instead. With the quantreg function call summary() around your rq object and it should give you upper and lower bands. – JustGettinStarted Jan 15 '19 at 19:24
  • Thank you for the feedback. I will answer my own question for the record if I figure it out and get no other responses. – Thomas Jan 16 '19 at 12:49

2 Answers2

0

The function predict.rq is analogous in use and meaning to predict.lm (both can be called by simply using predict). I could not get this to return a useful result using the default fitted values (it returns a vector instead of a matrix). My workaround was to define a newdata dataframe consisting of the fitted values and specifying that in the call to predict.rq.

Thomas
  • 1,071
0

To mimic the behavior of predict.lm() with default newdata one can use:

predict(mf, newdata = data.frame(x = mf$x, y = fitted(mf)), interval = "confidence")

assuming mf is the value returned by rq(), i.e., the fitted model object, and that the response variable was called y and the independent variable x in the data used to fit mf.