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.
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),
verbose = FALSE,
…)
fitted values; you probably want the default here.
residuals to use. Default: Weighted ("Pearson") residuals if weights have been used for the model fit.
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 title to plot. Default: sophisticated, resulting in
something like "Tukey-Anscombe Plot of : y \~ x" constructed from
lm.res $ call
.
x-axis label for plot.
logical; if TRUE
, draw a lowess
smoother
(with automatic smoothing fraction).
logical; if TRUE
, write the "call"ing syntax with
which the fit was done.
logical; if TRUE
, draw horizontal lines at
mad(resid)
.
positive integer, giving the number of lowess
robustness iterations. The default depends on the model and
is 0
for non Gaussian glm
's.
character expansion ("cex") for lowess and other marginal texts.
a list of arguments (with reasonable defaults) to be passed to
abline(.)
when drawing the x-axis, i.e.,
the
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.
logical indicating if some construction details should
be reported (print()
ed).
further graphical parameters are passed to
n.plot(.)
.
The above mentioned plot is produced on the current graphic device.
plot.lm
which also does a QQ normal plot and more.
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) { <!-- %% from S-plus -->
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
}
Run the code above in your browser using DataLab