Creates plots for examining the possible dependence of spread on level, or an extension of these plots to the studentized residuals from linear models.
spreadLevelPlot(x, ...)slp(...)
# S3 method for formula
spreadLevelPlot(x, data=NULL, subset, na.action, 
    main=paste("Spread-Level Plot for", varnames[response], 
    "by", varnames[-response]), ...)
# S3 method for default
spreadLevelPlot(x, by, robust.line=TRUE, 
	start=0, xlab="Median", ylab="Hinge-Spread", point.labels=TRUE, las=par("las"),
	main=paste("Spread-Level Plot for", deparse(substitute(x)), 
		"by", deparse(substitute(by))), col=palette()[1], col.lines=palette()[2],
    pch=1, lwd=2, grid=TRUE, ...)
# S3 method for lm
spreadLevelPlot(x, robust.line=TRUE, 
    smoother=loessLine, smoother.args=list(),
	xlab="Fitted Values",
	ylab="Absolute Studentized Residuals", las=par("las"),
	main=paste("Spread-Level Plot for\n", deparse(substitute(x))),
	pch=1, col=palette()[1], col.lines=palette()[2], col.smoother=palette()[3],
	lwd=2, grid=TRUE, 	labels, 
	id.method = "mahal", 
	id.n = if(id.method[1]=="identify") Inf else 0,
	id.cex=1, id.col=palette()[1], id.location="lr", ...)
	  
# S3 method for spreadLevelPlot
print(x, ...)
a formula of the form y ~ x, where y is a numeric vector
    and x is a factor, or an lm object to be plotted; alternatively a numeric vector.
an optional data frame containing the variables to be plotted. 
    By default the variables are taken from the environment from which 
    spreadLevelPlot is called.
an optional vector specifying a subset of observations to be used.
a function that indicates what should happen when the data contain NAs. 
    The default is set by the na.action setting of options.
a factor, numeric vector, or character vector defining groups.
if TRUE a robust line is fit using the rlm function in
    the MASS package; if FALSE a line is fit using lm.
a function to draw a nonparametric-regression smooth; the default is loessLine,
    which does loess smoothing.  The function gamLine fits a generalized additive model and
    allows including a link and error function.
    See ScatterplotSmoothers.
    Setting this argument to something other than a function, e.g., FALSE suppresses the smoother.
a list of named values to be passed to the smoother function; the specified elements of the
    list depend upon the smoother (see ScatterplotSmoothers).
add the constant start to each data value.
title for the plot.
label for horizontal axis.
label for vertical axis.
if TRUE label the points in the plot with group names.
if 0, ticks labels are drawn parallel to the
    axis; set to 1 for horizontal labels (see par).
color for lines; default is the second entry in the current palette
color for smooth line; default is third entry in the current palette.
plotting character for points; default is 1 
    (a circle, see par).
line width; default is 2 (see par).
If TRUE, the default, a light-gray background grid is put on the graph
Arguments for the labelling of
    points.  The default is id.n=0 for labeling no points with the lm method.  See
    showLabels for details of these arguments.
arguments passed to plotting functions.
An object of class spreadLevelPlot containing:
a matrix with the lower-hinge, median, upper-hinge, and hinge-spread
    for each group. (Not for an lm object.)
spread-stabilizing power transformation, calculated as \(1 - slope\) of the line fit to the plot.
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). Point labeling was added in November, 2016.
The function slp is an abbreviation for spreadLevelPlot.
Fox, J. (2008) Applied Regression Analysis and Generalized Linear Models, Second Edition. Sage.
Fox, J. and Weisberg, S. (2011) An R Companion to Applied Regression, Second Edition, Sage.
Hoaglin, D. C., Mosteller, F. and Tukey, J. W. (Eds.) (1983) Understanding Robust and Exploratory Data Analysis. Wiley.
spreadLevelPlot(interlocks + 1 ~ nation, data=Ornstein)
slp(lm(interlocks + 1 ~ assets + sector + nation, data=Ornstein))
Run the code above in your browser using DataLab