scatterplotMatrix: Scatterplot Matrices

Description Usage Arguments Value Author(s) References See Also Examples

Description

Enhanced scatterplot matrices with univariate displays down the diagonal; spm is an abbreviation for scatterplotMatrix. This function just sets up a call to pairs with custom panel functions.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
scatterplotMatrix(x, ...)

## S3 method for class 'formula'
scatterplotMatrix(formula, data=NULL, subset, id=FALSE, ...)

## Default S3 method:
scatterplotMatrix(x, smooth=TRUE, id=FALSE, legend=TRUE, 
    var.labels=colnames(x), 
    diagonal=c("density", "boxplot", "histogram", "oned", "qqplot", "none"), 
    adjust=1, nclass, plot.points=TRUE, spread = !by.groups, reg.line=lm,
    transform=FALSE, family=c("bcPower", "yjPower"), ellipse=FALSE, 
    groups=NULL, by.groups=FALSE, use=c("complete.obs", "pairwise.complete.obs"),
    col=if (n.groups == 1) palette()[3:1] else rep(palette(), length=n.groups),
    pch=1:n.groups, lwd=1, lty=1, 
    cex=par("cex"), cex.axis=par("cex.axis"), cex.labels=NULL, 
    cex.main=par("cex.main"), row1attop=TRUE, ...)

spm(x, ...)

Arguments

x

a data matrix, numeric data frame.

formula

a one-sided “model” formula, of the form ~ x1 + x2 + ... + xk or ~ x1 + x2 + ... + xk | z where z evaluates to a factor or other variable to divide the data into groups.

data

for scatterplotMatrix.formula, a data frame within which to evaluate the formula.

subset

expression defining a subset of observations.

smooth

specifies the smoother to be used along with its arguments; if FALSE, no smoother is shown; can be a list giving the smoother function and its named arguments; TRUE, the default, is equivalent to list(smoother=loessLine). See ScatterplotSmoothers for the smoothers supplied by the car package and their arguments.

id

controls point identification; if FALSE (the default), no points are identified; can be a list of named arguments to the showLabels function; TRUE is equivalent to list(method="mahal", n=2, cex=1, col=palette()[1], location="lr"), which identifies the 2 points (in each group, if by.groups=TRUE) with the largest Mahalanobis distances from the center of the data; list(method="identify") for interactive point identification is not allowed.

legend

controls placement of a legend if the plot is drawn by groups; if FALSE, the legend is suppressed. Can be a list with the named elementcoords specifying the position of the legend in any form acceptable to the legend function; TRUE (the default) is equivalent to list(coords=NULL), for which placement will vary by the the value of the diagonal argument—e.g., "topright" for diagonal="density".

var.labels

variable labels (for the diagonal of the plot).

diagonal

contents of the diagonal panels of the plot. If plotting by groups, a different univariate display (with the exception of "histogram") will be drawn for each group.

adjust

relative bandwidth for density estimate, passed to density function.

nclass

number of bins for histogram, passed to hist function.

plot.points

if TRUE the points are plotted in each off-diagonal panel.

spread

if TRUE, estimate the (square root) of the variance function. For loessLine and for gamLine, this is done by separately smoothing the squares of the postive and negative residuals from the mean fit, and then adding the square root of the fitted values to the mean fit. For quantregLine, fit the .25 and .75 quantiles with a quantile regression additive model. The default is TRUE if by.groups=FALSE and FALSE is by.groups=TRUE.

reg.line

if not FALSE a line is plotted using the function given by this argument; e.g., using rlm in package MASS plots a robust-regression line.

transform

if TRUE, multivariate normalizing power transformations are computed with powerTransform, rounding the estimated powers to ‘nice’ values for plotting; if a vector of powers, one for each variable, these are applied prior to plotting. If there are groups and by.groups is TRUE, then the transformations are estimated conditional on the groups factor.

family

family of transformations to estimate: "bcPower" for the Box-Cox family or "yjPower" for the Yeo-Johnson family (see powerTransform).

ellipse

controls plotting data-concentration ellipses. If FALSE (the default), no ellipses are plotted. Can be a list of named values giving levels, a vector of one or more bivariate-normal probability-contour levels at which to plot the ellipses; and robust, a logical value determing whether to use the cov.trob function in the MASS package to calculate the center and covariance matrix for the data ellipses. TRUE is equivalent to list(levels=c(.5, .95), robust=TRUE).

groups

a factor or other variable dividing the data into groups; groups are plotted with different colors and plotting characters.

by.groups

if TRUE, regression lines are fit by groups.

use

if "complete.obs" (the default), cases with missing data are omitted; if "pairwise.complete.obs"), all valid cases are used in each panel of the plot.

pch

plotting characters for points; default is the plotting characters in order (see par).

col

colors for lines and points; the default is taken from the color palette, with palette()[3] for linear regression lines, palette()[2] for nonparametric regression lines, and palette()[1] for points if there are no groups, and successive colors for the groups if there are groups.

lwd

width of linear-regression lines (default 1).

lty

type of linear-regression lines (default 1, solid line).

cex, cex.axis, cex.labels, cex.main

set sizes of various graphical elements (see par).

row1attop

If 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.

Value

NULL. This function is used for its side effect: producing a plot.

Author(s)

John Fox jfox@mcmaster.ca

References

Fox, J. and Weisberg, S. (2011) An R Companion to Applied Regression, Second Edition, Sage.

See Also

pairs, scatterplot, dataEllipse, powerTransform, bcPower, yjPower, cov.trob, showLabels, ScatterplotSmoothers.

Examples

1
2
3
4
5
scatterplotMatrix(~ income + education + prestige | type, data=Duncan)
scatterplotMatrix(~ income + education + prestige, 
    transform=TRUE, data=Duncan, id=TRUE, smooth=list(smoother=gamLine))
scatterplotMatrix(~ income + education + prestige | type, smooth=FALSE, 
	by.group=TRUE, transform=TRUE, ellipse=TRUE, data=Duncan)

jonathon-love/car3 documentation built on May 19, 2019, 7:28 p.m.