Conditioning Plot
DESCRIPTION:
The
coplot function produces a Conditioning Plot in the current
graphics device which shows how a response depends on a predictor
given another predictor.
USAGE:
coplot(formula, data, given.values, panel = points, rows, columns,
column.row, show.given = T, add = F, xlab, ylab, xlim, ylim, ...)
REQUIRED ARGUMENTS:
- formula
-
formula defining the response and the predictors involved
in the plotting.
OPTIONAL ARGUMENTS:
- data
-
data frame in which the formula will be evaluated.
If missing, evaluation will take place as if the formula were
evaluated in the frame of the function calling
coplot.
- given.values
-
a numeric vector, character vector, or two-column matrix that
specifies the given values when there is one given predictor, or a
list of two such objects when there are two. If missing, reasonable things
happen.
- panel
-
a user-supplied function of
x and
y that
determines the method of plotting on the dependence panels.
- rows
-
for the case of one given predictor,
the number of rows of the matrix of dependence panels.
If missing, the following is the default:
let
k be the number of given values; if
columns is missing,
then it is
ceiling(sqrt(k))
and otherwise it is
ceiling(k/columns).
This argument is not used if there are two given predictors.
- columns
-
for the case of one given predictor,
the number of columns of the matrix of dependence panels.
If missing, the following is the default:
let
k be the number of given values; if
rows is missing,
it is
ceiling(k/ceiling(sqrt(k))) and otherwise it is
ceiling(k/rows).
This argument is not used if there are two given predictors.
- column.row
-
when conditioning on only one predictor, a vector of length 2
describing the arrangement of panels in the plot, i.e. a vector
of the form
c(n,m) where
n and
m are integers indicating
the number of columns and rows, respectively for the arrangement
of the dependence panels. The default
is given by the arguments
columns and
rows which are overriden
by this argument, if specified.
- show.given
-
if
FALSE, given panels are not included.
- add
-
if
TRUE, add to the current plot.
Graphical parameters may also be supplied as arguments to
this function (see
par
).
The arguments
xlab and
ylab
are as for other graphics functions, except that the
former is a character vector of labels for predictors. If
the elements have names, they are matched to the names in
formula; if not, the elements are assigned, in order,
according to the order in which they appear in formula. If
missing, the names of the predictors in formula are used.
The arguments
xlim and
ylim are axis limits as in other
graphics functions.
SIDE EFFECTS:
a plot is produced on the current graphics device.
par(mfrow) is
reset to
c(1,1) before the plot is drawn, that is, the plot will
take up the entire graphics area; no other plot can appear at the same
time.
BUGS:
coplot
does not recognize graphics parameters if the
panel argument is
suppled as a function definition (i.e.,
panel=function(x,y)...). In
this case, you must supply the graphics parameters in the definition of
the
panel function.
SEE ALSO:
co.intervals
,
panel.smooth
.
EXAMPLES:
# the following makes a coplot of NOx against C given E
# with smoothings of the scatterplots on the dependence panels:
E.intervals <- co.intervals(ethanol$E, 16, 0.25)
coplot(NOx ~ C | E, given.values = E.intervals, data = ethanol,
panel = function(x, y) panel.smooth(x, y, span = 1,
degree = 1))