| 1 |
\name{TA.plot} |
| 2 |
\alias{TA.plot} |
| 3 |
\title{Tukey-Anscombe Plot (Residual vs. Fitted) of a Linear Model} |
| 4 |
\description{ |
| 5 |
From a linear (or glm) model fitted, produce the so-called Tukey-Anscombe |
| 6 |
plot. Useful (optional) additions include: 0-line, lowess smooth, |
| 7 |
2sigma lines, and automatic labeling of observations. |
| 8 |
} |
| 9 |
\usage{ |
| 10 |
TA.plot(lm.res, |
| 11 |
fit= fitted(lm.res), res= residuals(lm.res, type="pearson"), |
| 12 |
labels= NULL, main= mk.main(), xlab = "Fitted values", |
| 13 |
draw.smooth= n >= 10, show.call = TRUE, show.2sigma= TRUE, |
| 14 |
lo.iter = NULL, lo.cex= NULL, |
| 15 |
par0line = list(lty = 2, col = "gray"), |
| 16 |
parSmooth = list(lwd = 1.5, lty = 4, col = 2), |
| 17 |
parSigma = list(lwd = 1.2, lty = 3, col = 4), |
| 18 |
verbose = FALSE, |
| 19 |
\dots) |
| 20 |
} |
| 21 |
\arguments{ |
| 22 |
\item{lm.res}{Result of \code{\link{lm}(..)}, \code{\link{aov}(..)}, |
| 23 |
\code{\link{glm}(..)} or a similar object.} |
| 24 |
\item{fit}{fitted values; you probably want the default here.} |
| 25 |
\item{res}{residuals to use. Default: \bold{Weighted} ("Pearson") residuals if |
| 26 |
weights have been used for the model fit.} |
| 27 |
\item{labels}{strings to use as plotting symbols for each point. |
| 28 |
Default(\code{NULL}): extract observations' names or use its sequence number. |
| 29 |
Use, e.g., "*" to get simple \code{*} symbols. |
| 30 |
} |
| 31 |
\item{main}{main title to plot. Default: sophisticated, resulting in |
| 32 |
something like "Tukey-Anscombe Plot of : y ~ x" constructed from |
| 33 |
\code{lm.res $ call}. |
| 34 |
} |
| 35 |
\item{xlab}{x-axis label for plot.} |
| 36 |
\item{draw.smooth}{logical; if \code{TRUE}, draw a \code{lowess} smoother |
| 37 |
(with automatic smoothing fraction).} |
| 38 |
\item{show.call}{logical; if \code{TRUE}, write the "call"ing syntax with |
| 39 |
which the fit was done.} |
| 40 |
\item{show.2sigma}{logical; if \code{TRUE}, draw horizontal lines at |
| 41 |
\eqn{\pm 2\sigma}{+- 2 sigma} where \eqn{\sigma} is \code{mad(resid)}.} |
| 42 |
\item{lo.iter}{positive integer, giving the number of lowess |
| 43 |
robustness iterations. The default depends on the model and |
| 44 |
is \code{0} for non Gaussian \code{\link{glm}}'s.} |
| 45 |
\item{lo.cex}{character expansion ("cex") for lowess and other |
| 46 |
marginal texts.} |
| 47 |
\item{par0line}{a list of arguments (with reasonable defaults) to be passed to |
| 48 |
\code{\link{abline}(.)} when drawing the x-axis, i.e., |
| 49 |
the \eqn{y = 0} line.} |
| 50 |
\item{parSmooth, parSigma}{each a list of arguments (with reasonable |
| 51 |
default) for drawing the smooth curve (if \code{draw.smooth} is |
| 52 |
true), or the horizontal sigma boundaries (if \code{show.2sigma} is |
| 53 |
true) respectively.} |
| 54 |
\item{verbose}{logical indicating if some construction details should |
| 55 |
be reported (\code{\link{print}()}ed).} |
| 56 |
\item{\dots}{further graphical parameters are passed to |
| 57 |
\code{\link{n.plot}(.)}.} |
| 58 |
} |
| 59 |
\section{Side Effects}{ |
| 60 |
The above mentioned plot is produced on the current graphic device. |
| 61 |
} |
| 62 |
\author{Martin Maechler, Seminar fuer Statistik, ETH Zurich, Switzerland; |
| 63 |
\email{[email protected]} |
| 64 |
} |
| 65 |
\seealso{\code{\link{plot.lm}} which also does a QQ normal plot and more. |
| 66 |
} |
| 67 |
\examples{ |
| 68 |
data(stackloss) |
| 69 |
TA.plot(lm(stack.loss ~ stack.x)) |
| 70 |
|
| 71 |
example(airquality) |
| 72 |
summary(lmO <- lm(Ozone ~ ., data= airquality)) |
| 73 |
TA.plot(lmO) |
| 74 |
TA.plot(lmO, label = "O") # instead of case numbers |
| 75 |
|
| 76 |
if(FALSE) { %% from S-plus |
| 77 |
TA.plot(lm(cost ~ age+type+car.age, claims, weights=number, na.action=na.omit)) |
| 78 |
} |
| 79 |
|
| 80 |
##--- for aov(.) : ------------- |
| 81 |
data(Gun, package = "nlme") |
| 82 |
TA.plot( aov(rounds ~ Method + Physique/Team, data = Gun)) |
| 83 |
|
| 84 |
##--- Not so clear what it means for GLM, but: ------ |
| 85 |
if(require(rpart)) { # for the two datasets only |
| 86 |
data(solder, package = "rpart") |
| 87 |
TA.plot(glm(skips ~ ., data = solder, family = poisson), cex= .6) |
| 88 |
|
| 89 |
data(kyphosis, package = "rpart") |
| 90 |
TA.plot(glm(Kyphosis ~ poly(Age,2) + Start, data=kyphosis, family = binomial), |
| 91 |
cex=.75) # smaller title and plotting characters |
| 92 |
} |
| 93 |
} |
| 94 |
\keyword{models} |
| 95 |
\keyword{regression} |
| 96 |
|