spread.level.plot {car} | R Documentation |
Creates plots for examining the possible dependence of spread on level, or an extension of these plots to the studentized residuals from linear models.
spread.level.plot(x, ...) slp(x, ...) spread.level.plot.formula(formula, data=NULL, subset, na.action, main=paste("Spread-Level Plot for", varnames[response], "by", varnames[-response]), ...) spread.level.plot.default(x, by, robust.line=any("MASS" == .packages(all = TRUE)), start=0, xlab="Median", ylab="Hinge-Spread", las=par('las'), main=paste("Spread-Level Plot for", deparse(substitute(x)), "by", col=palette()[2], pch=1, lwd=2, ...) spread.level.plot.lm(x, start=0, robust.line=any("MASS" == .packages(all = TRUE)), xlab="Fitted Values", ylab="Absolute Studentized Residuals", las=par("las"), main=paste("Spread-Level Plot for", deparse(substitute(x))), pch=1, col=palette()[2], lwd=2, ...) ## S3 method for class 'spread.level.plot': print(x, ...)
x |
a formula or an lm object to be plotted; alternatively a numeric vector. |
formula |
a formula of the form y~x , where y is a numeric vector
and x is a factor. |
data |
an optional data frame containing the variables to be plotted.
By default the variables are taken from the environment from which
spread.level.plot is called. |
subset |
an optional vector specifying a subset of observations to be used. |
na.action |
a function that indicates what should happen when the data contain NA s.
The default is set by the na.action setting of options . |
by |
a factor, numeric or character vector defining groups. |
robust.line |
if TRUE a robust line is fit using the rlm function in
the MASS package; if FALSE a line is fit using lm . |
start |
add the constant start to each data value. |
main |
title for the plot. |
xlab |
label for horizontal axis. |
ylab |
label for vertical axis. |
las |
if 0 , ticks labels are drawn parallel to the
axis; set to 1 for horizontal labels (see par ). |
col |
color for points and lines; the default is the second entry
in the current color palette (see palette
and par ). |
pch |
plotting character for points; default is 1
(a circle, see par ). |
lwd |
line width; default is 2 (see par ). |
... |
arguments passed to plotting functions. |
Except for linear models, computes the statistics for, and plots, a Tukey spread-level plot of log(hinge-spread) vs. log(median) for the groups; fits a line to the plot; and calculates a spread-stabilizing transformation from the slope of the line.
For linear models, plots log(abs(studentized residuals) vs. log(fitted values).
The function slp
is an abbreviation for spread.level.plot
.
A list containing:
Statistics |
a matrix with the lower-hinge, median, upper-hinge, and hinge-spread
for each group. (Not for an lm object.) |
PowerTransformation |
spread-stabilizing power transformation, calculated as 1 – slope of the line fit to the plot. |
John Fox jfox@mcmaster.ca
Fox, J. (1997) Applied Regression, Linear Models, and Related Methods. Sage.
Hoaglin, D. C., Mosteller, F. and Tukey, J. W. (Eds.) (1983) Understanding Robust and Exploratory Data Analysis. Wiley.
data(Ornstein) attach(Ornstein) spread.level.plot(interlocks+1~nation) ## $Statistics ## LowerHinge Median UpperHinge Hinge-Spread ## US 2 6.0 13 11 ## UK 4 9.0 14 10 ## CAN 6 13.0 30 24 ## OTH 4 15.5 24 20 ## ## $PowerTransformation ## [1] 0.1534487 mod<-lm(interlocks ~ assets + sector + nation) slp(mod) ## $PowerTransformation ## [1] 0.3222165 ## ## Warning message: ## Start = 3 added to fitted values to avoid 0 or negative values. in: spread.level.plot.lm(x, ...)