5

I would expect that a quantile regression gives forecasts for the quantiles that are monotonic, i.e.

enter image description here

However, the quantreg package in R generates forecasts that do not make sense at all, see the plot:

enter image description here

Is there a reason for that?

Example below.

library(quantreg)
library(ggplot2)
data(engel)

taus <- seq(0.01,0.99,0.01)
model_qr <- quantreg::rq(foodexp~income,tau=taus,data = engel)

test <- data.frame(income = 200,  foodexp=  300)
result <- data.frame(
            Forecast = as.numeric(predict(model_qr, test)),
            Quantile = taus *100 
            )

ggplot(result, aes(x = Quantile, y = Forecast)) +
    geom_point() 
HOSS_JFL
  • 765
  • 2
  • 9
  • 24
  • I don't think you coded anything wrong. I think this is probably more appropriate for the stats site though because I think it boils down to it just not quite working that way. It might sound counter-intuitive (and I could be wrong - I'm definitely not an expert in quantile regression) but the line that does the best job at predicting different quantiles might cross due to the way it works out with the way the loss functions are optimized. What you will see is that the predictions for a given quantile are monotonic with respect to the predictor. – Dason Jan 25 '19 at 15:53
  • 3
    The other thing to note is that you chose to predict for an income outside of the dataset. Extrapolating like this probably isn't the best idea. Heck - if you try to take it even further and predict for say income = -300 you'll see almost monotonic decreasing predictions. – Dason Jan 25 '19 at 15:56
  • 1
    The quantregGrowth package performs quantile regression optimization with monotonicity constraints. – G. Grothendieck Jan 25 '19 at 16:25
  • @Dason - yes, and HOSS_JFL might get a more intuitive result with `income = 1000` or something else similar inside the actual distribution. Including `foodexp= 300` is not needed as the prediction is of food expenditure – Henry Jan 25 '19 at 17:48

0 Answers0