# Advice on identifying curve shape using quantreg

I'm using the quantreg package to make a regression model using the 99th percentile of my values in a data set. Based on advice from a previous stackoverflow question I asked, I used the following code structure.

mod <- rq(y ~ log(x), data=df, tau=.99)
pDF <- data.frame(x = seq(1,10000, length=1000) )
pDF <- within(pDF, y <- predict(mod, newdata = pDF) )


which I show plotted on top of my data. I've plotted this using ggplot2, with an alpha value for the points. I think that the tail of my distribution is not being considered sufficiently in my analysis. Perhaps this is due to the fact that there are individual points, that are being ignored by the percentile type measurement.

One of the comments suggested that

The package vignette includes sections on nonlinear quantile regression and also models with smoothing splines etc.

Based on my previous question I assumed a logarithmic relationship, but I'm not sure if that is correct. I thought I could extract all the points at the 99th percentile interval and then examine them separately, but I'm not sure how to do that, or if that is a good approach. I would appreciate any advice on how to improve identifying this relationship.

• There are a couple of good questions on the site already talking about transforming data like this, see stats.stackexchange.com/q/1444/1036 or stats.stackexchange.com/q/298/1036 Mar 31, 2011 at 14:35
• Can you update the plot to add the conditional median? this seems to me more like a quantile crossing problem than a data transformation problem... Jul 13, 2011 at 17:53
• @user603 What do you mean by the conditional median? (I searched online but am not sure how to calculate it) Jul 13, 2011 at 18:46
• tau=0.5 in the rq() function. Jul 25, 2011 at 15:30
• If your goal is specifically to estimate the conditional 99th percentile, I'd vote for nonlinear quantile regression (of some sort--I don't know the R packages well), since it doesn't sound like you know the true functional form. I still wasn't clear to me from your previous question what the actual goal is, though, so I would reiterate the comment on your previous question from Spacedman Jan 4 at 17:01 Sep 12, 2011 at 16:07

library(splines)

The quantreg package has some special hooks for monotonic splines if that's of concern to you.