Help with a specific quantile regression problem

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Help with a specific quantile regression problem

Helio Santana
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)[2]]
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?

I would appreciate your comments.

Best regards,

Helio

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: Help with a specific quantile regression problem

Roger Koenker-3
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    [hidden email]            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 <[hidden email]> 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)[2]]
> 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?
>
> I would appreciate your comments.
>
> Best regards,
>
> Helio
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> [hidden email] mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.