This question doesn't specifically pertain to R
, but I
chose to use R
to illustrate it.
Consider the code for producing confidence bands round a (normal) qq-line:
library(car)
library(MASS)
b0<-lm(deaths~.,data=road)
qqPlot(b0$resid,pch=16,line="robust")
I'm looking for an explanation of (or alternative a link to a paper/online document explaining) how these confidence bands are constructed (I have seen a reference to Fox 2002 in the help files of R but sadly I don't have this book handy).
My question will be made more precise with an example.
Here's how R
computes these particular CI's (I've
shortened/simplified the code used in car::qqPlot
)
x<-b0$resid
good<-!is.na(x)
ord<-order(x[good])
ord.x<-x[good][ord]
n<-length(ord.x)
P<-ppoints(n)
z<-qnorm(P)
plot(z,ord.x,type="n")
coef<-coef(rlm(ord.x~z))
a<-coef[1]
b<-coef[2]
abline(a,b,col="red",lwd=2)
conf<-0.95
zz<-qnorm(1-(1-conf)/2)
SE<-(b/dnorm(z))*sqrt(P*(1-P)/n) #[WHY?]
fit.value<-a+b*z
upper<-fit.value+zz*SE
lower<-fit.value-zz*SE
lines(z,upper,lty=2,lwd=2,col="red")
lines(z,lower,lty=2,lwd=2,col="red")
The question is: what is the justification for
the formula used to compute these SE (e.g. the line SE<-(b/dnorm(z))*sqrt(P*(1-P)/n)
).
FWIW this formula is very different from the formula of the usual confidence bands used in linear regression