[R] Help with a specific quantile regression problem
Helio Santana
helio.santana.1997 at gmail.com
Fri Feb 24 12:10:27 CET 2017
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]]
More information about the R-help
mailing list