Enhanced scatterplot matrices with univariate displays down the diagonal;
spm is an abbreviation for
This function just sets up a call to
pairs with custom panel functions.
scatterplotMatrix(x, ...) ## S3 method for class 'formula': scatterplotMatrix(x, data=NULL, subset, labels, ...) ## S3 method for class 'default': scatterplotMatrix(x, var.labels = colnames(x), diagonal = c("density", "boxplot", "histogram", "oned", "qqplot", "none"), adjust = 1, nclass, plot.points = TRUE, smooth = TRUE, spread = smooth && !by.groups, span = 0.5, loess.threshold = 5, reg.line = lm, transform = FALSE, family = c("bcPower", "yjPower"), ellipse = FALSE, levels = c(0.5, 0.95), robust = TRUE, groups = NULL, by.groups = FALSE, labels, id.method="mahal", id.n=0, id.cex=1, id.col=palette(), col = if (n.groups == 1) palette()[3:1] else rep(palette(), length = n.groups), pch = 1:n.groups, lwd = 1, lwd.smooth = lwd, lwd.spread = lwd, lty = 1, lty.smooth = lty, lty.spread = 2, cex = par("cex"), cex.axis = par("cex.axis"), cex.labels = NULL, cex.main = par("cex.main"), legend.plot = length(levels(groups)) > 1, row1attop = TRUE, ...) spm(x, ...)
- a data matrix, numeric data frame, or a one-sided
modelformula, of the form
~ x1 + x2 + ... + xkor
~ x1 + x2 + ... + xk | zwhere
zevaluates to a factor or other variable to divide the
scatterplotMatrix.formula, a data frame within which to evaluate the formula.
- expression defining a subset of observations.
- Arguments for the labelling of
points. The default is
id.n=0for labeling no points. See
showLabelsfor details of these arguments. If the plot uses different colors for gr
- variable labels (for the diagonal of the plot).
- contents of the diagonal panels of the plot.
- relative bandwidth for density estimate, passed to
- number of bins for histogram, passed to
TRUEthe points are plotted in each off-diagonal panel.
TRUEa loess smooth is plotted in each off-diagonal panel.
TRUE(the default when not smoothing by groups), a smoother is applied to the root-mean-square positive and negative residuals from the loess line to display conditional spread and asymmetry.
- span for loess smoother.
- suppress the loess smoother if there are fewer than
loess.thresholdunique values (default, 5) of the variable on the vertical axis.
- if not
FALSEa line is plotted using the function given by this argument; e.g., using
MASSplots a robust-regression line.
TRUE, multivariate normalizing power transformations are computed with
powerTransform, rounding the estimated powers to `nice' values for plotting; if a vector of powers, o
- family of transformations to estimate:
"bcPower"for the Box-Cox family or
"yjPower"for the Yeo-Johnson family (see
TRUEdata-concentration ellipses are plotted in the off-diagonal panels.
- levels or levels at which concentration ellipses are plotted;
the default is
cov.trobfunction in the
MASSpackage to calculate the center and covariance matrix for the data ellipses.
- a factor or other variable dividing the data into groups; groups are plotted with different colors and plotting characters.
TRUE, regression lines are fit by groups.
- plotting characters for points; default is the plotting characters in
- colors for lines and points; the default is taken from the color palette,
palette()for linear regression lines,
palette()for nonparametric regression lines, and
palette()for points if there
- width of linear-regression lines (default
- width for smooth regression lines (default is the same as
- width for lines showing spread (default is the same as
- type of linear-regression lines (default
1, solid line).
- type of smooth regression lines (default is the same as
- width for lines showing spread (default is
2, broken line).
- cex, cex.axis, cex.labels, cex.main
- set sizes of various graphical elements
TRUEthen a legend for the groups is plotted in the first diagonal cell.
TRUE(the default) the first row is at the top, as in a matrix, as opposed to at the bottom, as in graph (argument suggested by Richard Heiberger).
- arguments to pass down.
NULL. This function is used for its side effect: producing a plot.
Fox, J. and Weisberg, S. (2011) An R Companion to Applied Regression, Second Edition, Sage.
scatterplotMatrix(~ income + education + prestige | type, data=Duncan) scatterplotMatrix(~ income + education + prestige, transform=TRUE, data=Duncan) scatterplotMatrix(~ income + education + prestige | type, smooth=FALSE, by.group=TRUE, transform=TRUE, data=Duncan)
## There is no definition of the plot that is produced - e.g. what are exactly the green and red lines. This should be written as the most important thing in the documentation. Documentation should focus on telling what the function exactly does - it is completely missing. library(car) print('There is no definition of the plot that is produced - e.g. what are exactly the green and red lines. This should be written as the most important thing in the documentation. Documentation should focus on telling what the function exactly does - it is completely missing.') scatterplotMatrix(~ income + education)