# [R] Help with a specific quantile regression problem

Roger Koenker rkoenker at illinois.edu
Fri Feb 24 19:52:46 CET 2017

```What ensures that the tau-th quantile of the residuals is (nearly) zero, is that there IS
an intercept in the model, this is one of the conditions required for the subgradient to
contain 0 provided there is an intercept, when there is no intercept there is constraint
to enforce this any more.

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                Urbana, IL 61801

> On Feb 24, 2017, at 5:10 AM, Helio Santana <helio.santana.1997 at gmail.com> wrote:
>
> Dear R community,
>
> I am a beginner in quantile regression and I have a question about a
> specific problem. I have used the quantreg package to fit a QR with
> inequality constrains:
>
> n <- 100
> p <- 5
> X <- matrix(rnorm(n*p),n,p)
> y <- 0.95*apply(X,1,sum)+rnorm(n)
> R <- cbind(0,rbind(diag(p),-diag(p)))
> r <- c(rep(0,p),-rep(1,p))
> model <- rq(y~X,R=R,r=r,method="fnc")
>
> So,
>
>> quantile(model\$residuals,0.5)
>> -6.68836e-11 (It should be close to 0)
>
>
> However, if I try to impose no intercept in the last problem:
>
> R <- cbind(0,rbind(diag(p),-diag(p)))
> R <- R[,2:dim(R)]
> r <- c(rep(0,p),-rep(1,p))
> model <- rq(y~X-1,R=R,r=r,method="fnc")
>
> I obtain:
>
>> quantile(model\$residuals,0.5)
>> -0.03465427
>
> As you can see, this quantile value is not close to 0 as I expected. Have I
> an error in the formulation of the QR?
>
> Is it possible to fit a QR with inequality constrains and no intercept?
>
> Is there another alternative for solving this kind of problem?
>
>
> Best regards,
>
> Helio
>
> 	[[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help