[R] package quantreg behaviour in weights in function rq,
roger koenker
rkoenker at uiuc.edu
Tue Jul 21 12:10:49 CEST 2009
Václav,
I think that the technical term for this is snafu. You are right of
course
that the magnitude of the weights should have no impact on the fitted
values. The good news is that the coefficient estimates satisfy this
obvious principle, but unfortunately the fitted.values component is
being
computed with the wrong form of the X matrix, so your plots are
misaligned. The immediate work around is to compute fitted values
from the original data and the coef component of the fit rather than
relying on the fitted.values component. Thanks for pointing this out,
I'll try to submit a repaired version of the package later in the day.
Roger
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 Jul 21, 2009, at 7:03 AM, Václav Varvařovský wrote:
> Dear all,
>
> I am having v.4.36 of Quantreg package and I noticed strange
> behaviour when
> weights were added. Could anyone please explain me what if the
> results are
> really strange or the behavioiur is normal. As an example I am using
> dataset
> Engel from the package and my own weights.
>
> x<-engel[1:50,1]
> y<-engel[1:50,2]
> w<-c(0.00123, 0.00050, 0.00126, 0.00183, 0.00036, 0.00100,
> 0.00122, 0.00133, 0.01208, 0.00126, 0.00102, 0.00183,
> 0.00063, 0.00134, 0.00084, 0.00087, 0.00118, 0.00894,
> 0.00105, 0.00154, 0.02829, 0.00095, 0.05943, 0.07003,
> 0.00692, 0.03610, 0.00316, 0.06862, 0.00439, 0.08974,
> 0.01960, 0.00185, 0.00348, 0.03597, 0.00210, 0.03929,
> 0.03535, 0.01463, 0.02254, 0.00089, 0.01495, 0.00178,
> 0.00351, 0.10338, 0.13662, 0.00157, 0.07689, 0.07304,
> 0.00194, 0.00142)
>
> windows(width = 8, height = 7)
> u1<-rq(y~x,tau=c(1:10/10-0.05),weights=w)
> #note that by taking weights = 500*w the points
> #are all moving down (i thought it should have been invariant to the
> magnitude of weights) when all the weights remaint the same
> plot(x,y,ylim=c(-1000,max(y)))
> points(x,u1$fitted.values[,3],col="blue",cex=0.5)
> #weighted - fitted values nearly match original values
>
>
> windows(width = 8, height = 7)
> u1<-rq(y~x,tau=c(1:10/10-0.05))
> plot(x,y,ylim=c(-1000,max(y)))
> points(x,u1$fitted.values[,3],col="blue",cex=0.5)
> #unweighted - fitted values form a line
>
> Why the weighted quantile regression does not produce a line?
>
> Thank you for answers.
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list
> 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.
More information about the R-help
mailing list