# [R] Quantile Regression in R

roger koenker rkoenker at uiuc.edu
Tue Jun 29 17:49:13 CEST 2004

```The short answer to your question is that  quantile regression
estimates are estimating linear conditional quantile functions,
just like lm() is used to estimate conditional mean functions.

A longer answer would inevitably involve unpleasant suggestions
that you should follow the posting guide:

a.)  send questions about packages to the maintainer, not R-help
b.)  not attach datasets in modes that are stripped by R-help
c.)  make a token effort to read the documentation and related
literature

url:	www.econ.uiuc.edu/~roger        	Roger Koenker
email	rkoenker at uiuc.edu			Department of Economics
vox: 	217-333-4558				University of Illinois
fax:   	217-244-6678				Champaign, IL 61820

On Jun 29, 2004, at 10:26 AM, Ali Hirsa wrote:

> I recently learn about Quantile Regression in R.
> I am trying to study two time series (attached) by Quantile Regression
> in R.
> I wrote the following code and do not know how to interpret the lines.
>
> What kind of information can I get from them? Correlation for
> quantiles,
> conditional probabilties (i.e. P(X in Quantile i | Y in Quantile i)) ,
> and etc.
> Many thanks in advance for any help.
>
> Best,
> Ali
>
> library("quantreg")
> #help.start()
>
> #
> x <- Data[,2]
> y <- Data[,1]
>
> par(mfrow=c(2,2))
>
> qqnorm(x,main="MOVE Norm Q-Q Plot", xlab="Normal Qunatiles",ylab =
> "MOVE Quantiles")
> qqline(x)
>
> qqnorm(y,main="Residuals Norm Q-Q Plot", xlab="Normal Qunatiles",ylab
> = "Residuals Quantiles")
> qqline(y)
>
> plot(x,y,xlab="MOVE",ylab="Residuals",cex=.5)
>
> xx <- seq(min(x),max(x),.5)
>
> # Just a linear regression
> g <- coef(lm(y~x))
> yy <- (g+g*(xx))
> lines(xx,yy,col="yellow")
>
> taus <- c(.05,.1,.25,.5,.75,.9,.95)
>
> for(tau in taus){
>         f <- coef(rq(y~x,tau=tau,method="pfn"))
>         yy <- (f+f*(xx))
>         if (tau ==.05){
>              lines(xx,yy,col="red")
>         }
>         if (tau ==.95){
>              lines(xx,yy,col="green")
>         }
>         if (tau != .05 & tau != .95){
>              lines(xx,yy,col="blue")
>         }
> }
>
>
>
>
> __________________________________
>
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help