RDX2 X  plot6.lm sourceÓ =function (x, which = 1:4, caption = c("Residuals vs Fitted",  = "Normal Q-Q", "Scale-Location", I "Cook's distance", "Residuals vs Leverage", > "Cook's distance vs Leverage"),  F panel = points, sub.caption = deparse(x$call), main = "",  K ask = prod(par("mfcol")) < length(which) && dev.interactive(),  J ..., id.n = 3, labels.id = names(residuals(x)), cex.id = 0.75, 6 cook.levels=c(0.5, 1.0), label.pos=c(4,2)) {  if (!inherits(x, "lm"))  & stop("Use only with 'lm' objects") > if (!is.numeric(which) || any(which < 1) || any(which > 6))  " stop("`which' must be in 1:6")  isGlm <- inherits(x, "glm")  show <- rep(FALSE, 6)  show[which] <- TRUE  r <- residuals(x)  yh <- predict(x)  w <- weights(x)  if (!is.null(w)) {  wind <- w != 0  r <- r[wind]  yh <- yh[wind]  w <- w[wind] labels.id <- labels.id[wind]  }  n <- length(r)  if (any(show[2:6])) { ! s <- if (inherits(x, "rlm"))  x$s ) else sqrt(deviance(x)/df.residual(x)) / hii <- lm.influence(x, do.coef = FALSE)$hat  if (any(show[4:6])) { ) cook <- if (isGlm)cooks.distance(x) - else cooks.distance(x, sd = s, res = r)  }  }  if (any(show[c(2:3,5)])) {  ylab23 <- if (isGlm)   "Std. deviance resid." ! else "Standardized residuals"  r.w <- if (is.null(w))   r  else sqrt(w) * r ! rs <- r.w/(s * sqrt(1 - hii))  }  if (any(show[5:6])) {  hatval <- hatvalues(x)  }  if (any(show[c(1, 3)]))   l.fit <- if (isGlm)   "Predicted values"  else "Fitted values"  if (is.null(id.n))  id.n <- 0  else {  id.n <- as.integer(id.n)  if (id.n < 0 || id.n > n)  . stop("`id.n' must be in {1,..,", n, "}")  }  if (id.n > 0) {  if (is.null(labels.id))   labels.id <- paste(1:n)  iid <- 1:id.n 7 show.r <- sort.list(abs(r), decreasing = TRUE)[iid]  if (any(show[2:3]))  ; show.rs <- sort.list(abs(rs), decreasing = TRUE)[iid] 2 text.id <- function(x, y, ind, adj.x = FALSE){  midx <- mean(range(x))  labpos <- if (!adj.x) 3 else ' label.pos[1+as.numeric(x>midx)] F text(x, y, labels.id[ind], cex = cex.id, xpd = TRUE, pos=labpos,  offset=0.25)  }  } $ one.fig <- prod(par("mfcol")) == 1 if (ask) {  op <- par(ask = TRUE)  on.exit(par(op))  }  if (show[1]) { " ylim <- range(r, na.rm = TRUE)  if (id.n > 0)  1 ylim <- ylim + c(-1, 1) * 0.08 * diff(ylim) ? plot(yh, r, xlab = l.fit, ylab = "Residuals", main = main,  & ylim = ylim, type = "n", ...)  panel(yh, r, ...)  if (one.fig)  # title(sub = sub.caption, ...)  mtext(caption[1], 3, 0.25)  if (id.n > 0) {  y.id <- r[show.r] > y.id[y.id < 0] <- y.id[y.id < 0] - strheight(" ")(" ")/3 5 text.id(yh[show.r], y.id, show.r, adj.x = TRUE)  } ( abline(h = 0, lty = 3, col = "gray")  }  if (show[2]) { # ylim <- range(rs, na.rm = TRUE) + ylim[2] <- ylim[2] + diff(ylim) * 0.075 > qq <- qqnorm(rs, main = main, ylab = ylab23, ylim = ylim,   ...)  if (one.fig)  # title(sub = sub.caption, ...)  mtext(caption[2], 3, 0.25)  if (id.n > 0)  B text.id(qq$x[show.rs], qq$y[show.rs], show.rs, adj.x = TRUE)  }  if (show[3]) {  sqrtabsr <- sqrt(abs(rs)) - ylim <- c(0, max(sqrtabsr, na.rm = TRUE)) N yl <- as.expression(substitute(sqrt(abs(YL)), list(YL = as.name(ylab23))))  yhn0 <- if (is.null(w))   yh  else yh[w != 0] ? plot(yhn0, sqrtabsr, xlab = l.fit, ylab = yl, main = main,  & ylim = ylim, type = "n", ...)  panel(yhn0, sqrtabsr, ...)  if (one.fig)  # title(sub = sub.caption, ...)  mtext(caption[3], 3, 0.25)  if (id.n > 0)  9 text.id(yhn0[show.rs], sqrtabsr[show.rs], show.rs,   adj.x = TRUE)  }  if (show[4]) {  if (id.n > 0) { ! show.r <- order(-cook)[iid] $ ymx <- cook[show.r[1]] * 1.075  }  else ymx <- max(cook) : plot(cook, type = "h", ylim = c(0, ymx), main = main,  = xlab = "Obs. number", ylab = "Cook's distance", ...)  if (one.fig)  # title(sub = sub.caption, ...)  mtext(caption[4], 3, 0.25)  if (id.n > 0)  8 text.id(show.r, cook[show.r], show.r, adj.x=FALSE)  }  if (show[5]) {  # ylim <- range(rs, na.rm = TRUE)  if (id.n > 0) { 1 ylim <- ylim + c(-1, 1) * 0.08 * diff(ylim) ! show.r <- order(-cook)[iid]  } / plot(hatval, rs, ylim = ylim, main = main,  + xlab = "Leverages", ylab = ylab23,  type="n", ...)  panel(hatval, rs, ...)  if (one.fig)  # title(sub = sub.caption, ...)  p <- length(coef(x))  for(crit in cook.levels){ / curve(sqrt(crit*p*(1-x)/x), lty=2, add=T) 0 curve(-sqrt(crit*p*(1-x)/x), lty=2, add=T)  }  xmax <- par()$usr[2] " ymult <- sqrt(p*(1-xmax)/xmax) D aty <- c(-sqrt(rev(cook.levels))*ymult, sqrt(cook.levels)*ymult) C axis(4, at=aty, labels=paste(c(rev(cook.levels), cook.levels)), 9 mgp=c(.25,.25,0), las=2, tck=0, cex.axis=cex.id)  mtext(caption[5], 3, 0.25)  if (id.n > 0) {  y.id <- rs[show.r] 9 y.id[y.id < 0] <- y.id[y.id < 0] - strheight(" ")/3 O text(hatval[show.r], y.id, paste(show.r), pos=2, cex=cex.id, offset=0.25)  }  }  if (show[6]) {   ymx <- max(cook)*1.025  g <- hatval/(1-hatval) C plot(g, cook, ylim = c(0, ymx), main = main, xlab = "Leverage", ' xaxt = "n", xlim=c(0, max(g)), 1 ylab = "Cook's distance", type="n", ...)  athat <- pretty(hatval) 4 axis(1, at=athat/(1-athat), labels=paste(athat))  panel(g, cook, ...)  if (one.fig)  # title(sub = sub.caption, ...)  p <- length(coef(x)) % bval <- pretty(sqrt(p*cook/g), 5)  xmax <- par()$usr[2]  ymax <- par()$usr[4]  for(i in 1:length(bval)) {  bi2 <- bval[i]^2  if(ymax > bi2*xmax) { $ xi <- xmax + strwidth(" ")/3  yi <- bi2*xi  abline(0, bi2, lty=2) 2 text(xi, yi, paste(bval[i]), adj=0, xpd=T) } else  { ' yi <- ymax - 1.5*strheight(" ")  xi <- yi/bi2 ( lines(c(0, xi), c(0, yi), lty=2) I text(xi, ymax-0.8*strheight(" "), paste(bval[i]), adj=0.5, xpd=T)  }  }  xmax <- par()$usr[2] S ## axis(4, at=p*cook.levels, labels=paste(c(rev(cook.levels), cook.levels)), ? ## mgp=c(.25,.25,0), las=2, tck=0, cex.axis=cex.id)  mtext(caption[6], 3, 0.25)  if (id.n > 0)  ! show.r <- order(-cook)[iid] 8 text.id(g[show.r], cook[show.r], show.r, adj.x=TRUE)  } & if (!one.fig && par("oma")[3] >= 1)  0 mtext(sub.caption, outer = TRUE, cex = 1.25) invisible() }þý xû$ which :?ð@þ caption c Residuals vs Fitted Normal Q-Q Scale-Location Cook's distance Residuals vs Leverage Cook's distance vs Leverageþ panel points sub.caption deparse $ÿ callþþ main  ask && < prod par mfcolþþ lengthÿþþ dev.interactiveþþ ...û id.n@ labels.id names residualsÿþþ cex.id?è cook.levelsÿ?à?ðþ label.posÿ@@þþ { if ! inheritsÿ lmþþ stop Use only with 'lm' objectsþþÿ ||"ÿÿ is.numericÿþþ anyÿÿ?ðþþþ$ÿ >ÿ@þþþ!ÿ `which' must be in 1:6þþ <- isGlm ÿÿ glmþþ&ÿ show rep @þþ&ÿ [(ÿÿþ þ&ÿ rÿÿþþ&ÿ yh predictÿþþ&ÿ w weightsÿþþÿÿ is.null.ÿþþÿ&ÿ wind !=.ÿþþ&ÿ+ÿ*ÿ+ÿ1ÿþþ&ÿ,ÿ*ÿ,ÿ1ÿþþ&ÿ.ÿ*ÿ.ÿ1ÿþþ&ÿÿ*ÿÿ1ÿþþþþ&ÿ nÿ+ÿþþÿ$ÿ*ÿ(ÿÿ@@þþþÿ&ÿ sÿ ÿÿ rlmþ ÿÿ4ÿþ sqrt / devianceÿþ df.residualÿþþþþþ&ÿ hii ÿ lm.influenceÿ do.coef þ hatþþÿ$ÿ*ÿ(ÿÿ@@þþþÿ&ÿ cookÿ'ÿ cooks.distanceÿþ=ÿÿ sd4ÿ res+ÿþþþþþþþÿ$ÿ*ÿ(ÿÿÿ@@þ@þþþÿ&ÿ ylab23ÿ'ÿ Std. deviance resid. Standardized residualsþþ&ÿ r.wÿ0ÿ.ÿþ+ÿ *5ÿ.ÿþ+ÿþþþ&ÿ rs6ÿAÿ (Bÿ4ÿ5ÿ -?ð9ÿþþþþþþþþÿ$ÿ*ÿ(ÿÿ@@þþþÿ&ÿ hatval hatvaluesÿþþþþÿ$ÿ*ÿ(ÿÿ?ð@þþþ&ÿ l.fitÿ'ÿ Predicted values Fitted valuesþþþÿ0ÿÿþ&ÿÿþÿ&ÿÿ as.integerÿþþÿ"ÿÿÿþ%ÿÿ3ÿþþ!ÿ `id.n' must be in {1,..,3ÿ }þþþþÿ%ÿÿþÿÿ0ÿÿþ&ÿÿ pasteÿ?ð3ÿþþþþ&ÿ iidÿ?ðÿþþ&ÿ show.r*ÿ sort.list abs+ÿþ decreasing þKÿþþÿ$ÿ*ÿ(ÿÿ@@þþþ&ÿ show.rs*ÿMÿNÿCÿþOÿ þKÿþþþ&ÿ text.id functionÿû yû indû$ adj.x þÿ&ÿ midx mean rangeÿþþþ&ÿ labposÿÿUÿþ@*ÿÿ +?ð as.numeric%ÿÿVÿþþþþþþ textÿSÿ*ÿÿTÿþ cexÿ xpd  posYÿ offset?Ðþþ #function(x, y, ind, adj.x = FALSE){  midx <- mean(range(x))  labpos <- if (!adj.x) 3 else ' label.pos[1+as.numeric(x>midx)] F text(x, y, labels.id[ind], cex = cex.id, xpd = TRUE, pos=labpos,  offset=0.25)  }þþþþ&ÿ one.fig ==ÿÿ mfcolþþ?ðþþÿÿÿ&ÿ opÿÿ þþ on.exitÿcÿþþþþÿ*ÿ(ÿ?ðþÿ&ÿ ylimXÿ+ÿ na.rm þþÿ%ÿÿþ&ÿeÿZÿeÿBÿBÿÿEÿ?ðþ?ðþ?´záG®{þ diffeÿþþþþþ plot,ÿ+ÿ xlabHÿ ylab Residuals ÿ ÿeÿeÿ type nÿþÿ,ÿ+ÿÿþÿaÿ title sub ÿÿþþ mtext*ÿÿ?ðþ@?Ðþÿ%ÿÿþÿ&ÿ y.id*ÿ+ÿLÿþþ&ÿ*ÿoÿÿoÿþþEÿ*ÿoÿÿoÿþþ6ÿ strheight  þ  þ@þþþQÿ*ÿ,ÿLÿþoÿLÿUÿ þþþ abline h lty@ col grayþþþÿ*ÿ(ÿ@þÿ&ÿeÿXÿCÿfÿ þþ&ÿ*ÿeÿ@þZÿ*ÿeÿ@þBÿgÿeÿþ?³333333þþþ&ÿ qq qqnormCÿ ÿ ÿjÿ@ÿeÿeÿÿþþÿaÿlÿmÿ ÿÿþþnÿ*ÿÿ@þ@?Ðþÿ%ÿÿþQÿ*ÿ ÿuÿÿþPÿþ*ÿ ÿuÿSÿþPÿþPÿUÿ þþþþÿ*ÿ(ÿ@þÿ&ÿ sqrtabsr5ÿNÿCÿþþþ&ÿeÿÿ maxwÿfÿ þþþ&ÿ yl as.expression substitute5ÿNÿ YLþþ list|ÿ as.name@ÿþþþþþ&ÿ yhn0ÿ0ÿ.ÿþ,ÿ*ÿ,ÿ2ÿ.ÿþþþþhÿÿwÿiÿHÿjÿyÿ ÿ ÿeÿeÿkÿ nÿþÿÿwÿÿþÿaÿlÿmÿ ÿÿþþnÿ*ÿÿ@þ@?Ðþÿ%ÿÿþQÿ*ÿÿPÿþ*ÿwÿPÿþPÿUÿ þþþþÿ*ÿ(ÿ@þÿÿ%ÿÿþÿ&ÿLÿ*ÿ orderEÿ<ÿþþKÿþþ&ÿ ymxBÿ*ÿ<ÿ*ÿLÿ?ðþþ?ñ333333þþþ&ÿÿxÿ<ÿþþþhÿ<ÿkÿ heÿÿÿþ ÿ ÿiÿ Obs. numberjÿ Cook's distanceÿþÿaÿlÿmÿ ÿÿþþnÿ*ÿÿ@þ@?Ðþÿ%ÿÿþQÿLÿ*ÿ<ÿLÿþLÿUÿ þþþþÿ*ÿ(ÿ@þÿ&ÿeÿXÿCÿfÿ þþÿ%ÿÿþÿ&ÿeÿZÿeÿBÿBÿÿEÿ?ðþ?ðþ?´záG®{þgÿeÿþþþþ&ÿLÿ*ÿ€ÿEÿ<ÿþþKÿþþþþhÿFÿCÿeÿeÿ ÿ ÿiÿ Leveragesjÿ@ÿkÿ nÿþÿFÿCÿÿþÿaÿlÿmÿ ÿÿþþ&ÿ pÿ coefÿþþþ for critÿÿ curve5ÿ6ÿBÿBÿ…ÿ‚ÿþDÿEÿ?ðÿþþþÿþþsÿ@ add Tþ†ÿEÿ5ÿ6ÿBÿBÿ…ÿ‚ÿþDÿEÿ?ðÿþþþÿþþþsÿ@‡ÿˆÿþþþ&ÿ xmax*ÿ ÿÿþ usrþ@þþ&ÿ ymult5ÿ6ÿBÿ‚ÿDÿEÿ?ð‰ÿþþþ‰ÿþþþ&ÿ atyÿBÿEÿ5ÿ revÿþþþ‹ÿþBÿ5ÿÿþ‹ÿþþþ axis@ atŒÿ labelsJÿÿÿÿþÿþþ mgpÿ?Ð?Ðþ las@ tck cex.axisÿþnÿ*ÿÿ@þ@?Ðþÿ%ÿÿþÿ&ÿoÿ*ÿCÿLÿþþ&ÿ*ÿoÿÿoÿþþEÿ*ÿoÿÿoÿþþ6ÿpÿ  þ@þþþ\ÿ*ÿFÿLÿþoÿJÿLÿþ_ÿ@]ÿÿ`ÿ?Ðþþþþþÿ*ÿ(ÿ@þÿ&ÿÿBÿxÿ<ÿþ?ðffffffþþ&ÿ g6ÿFÿDÿEÿ?ðFÿþþþþhÿ•ÿ<ÿeÿÿÿþ ÿ ÿiÿ Leverage xaxt n xlimÿxÿ•ÿþþjÿ Cook's distancekÿ nÿþ&ÿ athat prettyFÿþþŽÿ?ðÿ6ÿ˜ÿDÿEÿ?ð˜ÿþþþÿJÿ˜ÿþþÿ•ÿ<ÿÿþÿaÿlÿmÿ ÿÿþþ&ÿ‚ÿÿƒÿÿþþþ&ÿ bval™ÿ5ÿ6ÿBÿ‚ÿ<ÿþ•ÿþþ@þþ&ÿ‰ÿ*ÿ ÿÿþ usrþ@þþ&ÿ ymax*ÿ ÿÿþ usrþ@þþ„ÿ iÿ?ðÿšÿþþÿ&ÿ bi2 ^*ÿšÿœÿþ@þþÿ%ÿ›ÿBÿÿ‰ÿþþÿ&ÿ xiZÿ‰ÿ6ÿ strwidth  þ@þþþ&ÿ yiBÿÿŸÿþþqÿÿsÿ@þ\ÿŸÿ¡ÿJÿ*ÿšÿœÿþþ adj^ÿˆÿþþÿ&ÿ¡ÿEÿ›ÿBÿ?øpÿ  þþþþ&ÿŸÿ6ÿ¡ÿÿþþ linesÿŸÿþÿ¡ÿþsÿ@þ\ÿŸÿEÿ›ÿBÿ?é™™™™™špÿ  þþþJÿ*ÿšÿœÿþþ¢ÿ?à^ÿˆÿþþþþþ&ÿ‰ÿ*ÿ ÿÿþ usrþ@þþnÿ*ÿÿ@þ@?Ðþÿ%ÿÿþ&ÿLÿ*ÿ€ÿEÿ<ÿþþKÿþþþQÿ*ÿ•ÿLÿþ*ÿ<ÿLÿþLÿUÿ þþþÿÿÿaÿþ >=*ÿÿ omaþ@þ?ðþþnÿ ÿ outer ]ÿ?ôþþ invisibleþþþ