[R] rearrange command in quantreg package

Dimitris.Kapetanakis dimitrios.kapetanakis at gmail.com
Sun Oct 10 22:20:40 CEST 2010



Dear all,

I want to use the "rearrange" command which is based on Chernozhukov et al
paper and is included in the quantreg package. So, I run a quantile
regression in which I included dummy variables for state and years in order
to estimate the respective fixed effects quantile regression. The problems
are the followings:

1. At example that is stated in the help****, I don't understand what the
income=quantile(income, 0.3) stands for, in the newdata argument of predict.
Why use a specific quantile since we estimate the response's quantile
prediction as a function of the quantile index? (If I understand correctly).
So, if I use the following code the predict command seems to work fine 

dyear<-dummy(ekc$year)[,-1]
dstate<-dummy(ekc$state)[,-1]

dekc<-cbind(ekc, dyear, dstate)

z.nox<-rq(nox~dyear+dstate+pcinc+I(pcinc^2)+I(pcinc^3), tau=-1, data=dekc)

zp.nox <- predict(z.nox,newdata=list(pcinc=ekc$pcinc,
dyear=dummy(ekc$year)[,-1], dstate=dummy(ekc$state)[,-1]), type="stepfun")
 
but when I am going to do the plot 

plot(zp.nox,do.points = FALSE, xlab = expression(tau), ylab = expression(Q (
tau )), main="Quantile Something")

the following error appears

Error in xy.coords(x, y, xlabel, ylabel, log) : 
  'x' is a list, but does not have components 'x' and 'y'

On the other hand when I using

 zp.nox <- predict(z.nox,newdata=list(pcinc=quantile(ekc$pcinc, 0.3),
dyear=dummy(ekc$year)[,-1], dstate=dummy(ekc$state)[,-1]), type="stepfun")

the following error appears:

Error in model.frame.default(Terms, newdata, na.action = na.action, xlev =
object$xlevels) : 
  variable lengths differ (found for 'pcinc')

and again it is not working if I put quantile in the dummies

Perhaps I am doing a stupid mistake since I haven't understood why we use
this 0.3 quantile in income

**** data(engel)
z <- rq(foodexp ~ income, tau = -1,data =engel)
zp <-
predict(z,newdata=list(income=quantile(engel$income,.03)),type="stepfun")
plot(zp,do.points = FALSE, xlab = expression(tau),
        ylab = expression(Q ( tau )), main="Engel Food Expenditure
Quantiles")
plot(rearrange(zp),do.points = FALSE, add=TRUE,col.h="red",col.v="red")
legend(.6,300,c("Before Rearrangement","After
Rearrangement"),lty=1,col=c("black","red"))

2. My initial target was to re-estimate the fitted curves
(nox=b1_hat*pcinc+b2_hat*pcinc^2+b3_hat*pcinc^3) without the quantile
crossing. Obviously the rearrange command does not do this. Does anybody
know how can I re-estimate (if possible) the quantile regressions without
the curves crossing for different quantiles?

Thanks a lot

-- 
View this message in context: http://r.789695.n4.nabble.com/rearrange-command-in-quantreg-package-tp2970611p2970611.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list