# [R] (-1 as index) OR (envelope for QQ)

Peter Dalgaard BSA p.dalgaard at biostat.ku.dk
Thu Feb 24 21:17:39 CET 2000

```"Dan E. Kelley" <kelley at Phys.Ocean.Dal.CA> writes:

> Content-Type: TEXT/PLAIN; charset=US-ASCII
>
> I'm new to R (and to S) and am wondering about code from pages 72 and
> 83 of MASS (Venables+Ripley, 3rd edition), to draw an envelope on a QQ
> plot.  Copying from the book, I've got:
>
>   #... code whose gist is "a.fit <-  nls(..."
>   num.points <- length(resid(a.fit))
>   qqnorm(residuals(a.fit))     # illustrate data-model residuals
>   qqline(residuals(a.fit))
>   samp <- cbind(residuals(a.fit), matrix(rnorm(num.points*19),num.points,19))
>   samp <- apply(scale(samp), 2, sort)
>   rs <- samp[,1]
>   xs <- qqnorm(rs, plot=FALSE)\$x
>   env <- t(apply(samp[,-1], 1, range))  ###########################3
>   xyul <- par("usr")
>   smidge <- min(diff(c(xyul[1], xs, xyul[2])))/2
>   segments(xs-smidge,env[,1], xs+smidge, env[,1])
>   segments(xs-smidge,env[,2], xs+smidge, env[,2])
>
....
> 1) You idiot!  QQ plots are supposed to have standardized residuals of
>    the data-model misfit.  Do that and the QQ envelop is ok.
>
> 2) Don't copy S stuff into R code.  The S code "samp[,-1]" from VR
>    should be written "..." for use in R.
>
> 3) Don't be so rude as to ask such questions (with length attachments,
>    no less) on a group like this.  Give us a break!
>
> ... but I'm hoping that the mode won't be in the final category!

Well, 2) is *not* the answer... Try removing the plot=F from the 2nd
qqnorm and I think you'll see the light. Notice the scale on the y
axis.

--
O__  ---- Peter Dalgaard             Blegdamsvej 3
c/ /'_ --- Dept. of Biostatistics     2200 Cph. N
(*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)             FAX: (+45) 35327907
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._

```