开发者

Quantile regression and p-values

I am applying guantile regression for my data-set (using R). It is easy to produce the nice scatterplot-image with different quantile regression lines (taus <- c(0.05,0.25,0.75,0.95)).

Problem occurs when I want to produce p-values (in order to see sta开发者_运维问答tistical significance of each regression line) for each one of these quantiles. For median quantile (tau=0.5) this is not problematic, but when it comes to for example tau=0.25, I get following error message:

>QRmodel<-rq(y~x,tau=0.25,model=T)
>summary(QRmodel,se="nid")
Error in summary.rq(QRmodel, se = "nid") : tau - h < 0:  error in summary.rq

What could be the reason for this?

Also: Is it recommendable to mention p-values and coefficients regarding the results of quantile regression model or could it be enough to show just the plot-picture and discuss the results based on that picture?

Best regards, frustrated person


A good way to learn what's going on in these sorts of debugging situations is to find the relevant portion of code that is throwing the error. If you type 'summary.rq' at the console, you'll see the code for the function summary.rq. Scanning through it you'll find the section where it calculates se's using the "nid" method, starting with this code:

else if (se == "nid") {
    h <- bandwidth.rq(tau, n, hs = hs)
    if (tau + h > 1) 
        stop("tau + h > 1:  error in summary.rq")
    if (tau - h < 0) 
        stop("tau - h < 0:  error in summary.rq")
    bhi <- rq.fit.fnb(x, y, tau = tau + h)$coef
    blo <- rq.fit.fnb(x, y, tau = tau - h)$coef

So what's happening here is that in order to calculate the se's, the function first need to calculate a bandwidth, h, and the quantreg model is refit for tau +/- h. For tau's near 0 or 1, there's a possibility that adding or subtracting the bandwidth 'h' will lead to a tau below 0 or greater than 1, which isn't good, so the function stops.

You have a couple of options:

1.) Try a different se method (bootstrapping?)

2.) Modify the summary.rq code yourself to force it to use either max(tau,0) or min(tau,1) in the instances where the bandwidth pushes tau out of bounds. (There could be serious theoretical reasons why this is a bad idea; not advised unless you know what you're doing.)

3.) You could try to read up on the theory behind the calculation of these se's so you'd have a better idea of when they might work well or not. This might shed some light on why you're running into errors with values of tau near 0 or 1.


Try summary(QRmodel,se="boot")

Have a look at the help for summary.rq as well!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜