TA.plot {sfsmisc}R Documentation

Tukey-Anscombe Plot (Residual vs. Fitted) of a Linear Model

Description

From a linear (or glm) model fitted, produce the so-called Tukey-Anscombe plot. Useful (optional) additions include: 0-line, lowess smooth, 2sigma lines, and automatic labeling of observations.

Usage

TA.plot(lm.res,
        fit= fitted(lm.res), res= residuals(lm.res, type="pearson"),
        labels= NULL, main= mk.main(), xlab = "Fitted values",
        draw.smooth= n >= 10, show.call = TRUE, show.2sigma= TRUE,
        lo.iter = NULL, lo.cex= NULL,
        par0line  = list(lty = 2, col = "gray"),
        parSmooth = list(lwd = 1.5, lty = 4, col = 2),
        parSigma  = list(lwd = 1.2, lty = 3, col = 4),
        ...)

Arguments

lm.res Result of lm(..), aov(..), glm(..) or a similar object.
fit fitted values; you probably want the default here.
res residuals to use. Default: Weighted ("Pearson") residuals if weights have been used for the model fit.
labels strings to use as plotting symbols for each point. Default(NULL): extract observations' names or use its sequence number. Use, e.g., "*" to get simple * symbols.
main main title to plot. Default: sophisticated, resulting in something like "Tukey-Anscombe Plot of : y \~ x" constructed from lm.res $ call.
xlab x-axis label for plot.
draw.smooth logical; if TRUE, draw a lowess smoother (with automatic smoothing fraction).
show.call logical; if TRUE, write the "call"ing syntax with which the fit was done.
show.2sigma logical; if TRUE, draw horizontal lines at +- 2 sigma where \sigma is mad(resid).
lo.iter positive integer, giving the number of lowess robustness iterations. The default depends on the model and is 0 for non Gaussian glm's.
lo.cex character expansion ("cex") for lowess and other marginal texts.
par0line a list of arguments (with reasonable defaults) to be passed to abline(.) when drawing the x-axis, i.e., the y = 0 line.
parSmooth, parSigma each a list of arguments (with reasonable default) for drawing the smooth curve (if draw.smooth is true), or the horizontal sigma boundaries (if show.2sigma is true) respectively.
... further graphical parameters are passed to n.plot(.).

Side Effects

The above mentioned plot is produced on the current graphic device.

Author(s)

Martin Maechler, Seminar fuer Statistik, ETH Zurich, Switzerland; maechler@stat.math.ethz.ch

See Also

plot.lm which also does a QQ normal plot and more.

Examples

data(stackloss)
TA.plot(lm(stack.loss ~ stack.x))

example(airquality)
summary(lmO <- lm(Ozone ~ ., data= airquality))
TA.plot(lmO)
TA.plot(lmO, label = "O") # instead of case numbers

if(FALSE) { 
 TA.plot(lm(cost ~ age+type+car.age, claims, weights=number, na.action=na.omit))
}

##--- for  aov(.) : -------------
data(Gun, package = "nlme")
TA.plot( aov(rounds ~ Method + Physique/Team, data = Gun))

##--- Not so clear what it means for GLM, but: ------
if(require(rpart)) { # for the two datasets only
 data(solder, package = "rpart")
 TA.plot(glm(skips ~ ., data = solder, family = poisson), cex= .6)

 data(kyphosis, package = "rpart")
 TA.plot(glm(Kyphosis ~ poly(Age,2) + Start, data=kyphosis, family = binomial),
	 cex=.75) # smaller title and plotting characters
}

[Package sfsmisc version 1.0-11 Index]