I have a dataset something like this (y variable vs Age, please ignore the green lines)

enter image description here

I want to add the quantile regression curves (0.025,0.05,0.5,0.95,0.975) to my plot. The problem is that the nature of observations between 0 to 1 (birth to one year old age) is completely different from (one year to 18 years). Any idea regarding working with this data set to calculate the reference curves?


1 Answer 1


It looks like the pattern is not really different between zero and one, but only between zero and some very small value.

Your best bet might be to fit different quantile regressions for your two regimes, essentially treating your data as a mixture. For the part near zero, it looks like you may simply want straight quantiles, not a quantile regression per se, especially if there is really only very little happening in terms of the $x$ coordinate.

  • $\begingroup$ thanks so much for your advice, Do you think it is a good idea that for when 1>age>0 I apply linear quantile regression (rq function in quantreg package) and for age>=1, I apply local polynomial quantile regression (lprq function in quantreg package)? $\endgroup$
    – shosho
    Jan 7, 2018 at 16:24
  • $\begingroup$ lprq sounds like a good idea for "larger" ages. Or simply use a low-order spline transformation of age and feed it into rq. For "smaller" ages (and you will need to take a good look at where to set the cutoff; 1 doesn't seem very good), I don't think you want to do a regression as such - simply take quantiles. $\endgroup$ Jan 7, 2018 at 16:33
  • $\begingroup$ @ Stephan Kolassa, thanks for the great suggestion. I donot know how to apply the spline transformation of age, do you mean applying X <- rq(y ~ bs(age, df=15))? Please correct me if I am wrong. Also, Is there any way to calculate the optimal value for df in spline smoothing and also the optimal value for bandwidth in lprq (polynomial quantile regression)? $\endgroup$
    – shosho
    Jan 8, 2018 at 1:03
  • $\begingroup$ bs is a good choice. You may want to look into Frank Harrell's Regression Modeling Strategies, which has a good discussion of splines. Regarding the optimal choice of knots and their locations, Harrell's textbook has a few rules of thumb, or alternatively, you could look to cross validation. $\endgroup$ Jan 8, 2018 at 15:31
  • $\begingroup$ sure, I will. Just could you please let me know why I should use the transformation of age? For example, Do I need to have a linear relationship between age and Y in order to apply lprq function? Also could you please check this question: stats.stackexchange.com/questions/322181/… $\endgroup$
    – shosho
    Jan 9, 2018 at 3:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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