The plot method for class design objects; other methods are part of a separate help page.
# S3 method for design
plot(x, y=NULL, select=NULL, selprop=0.25, ask=NULL, ...)
The plot
method is called for its side effects and returns NULL
.
data frame of S3 class design
a character vector of names of numeric variables in x
to be plotted as responses,
or a numeric response vector, or a numeric matrix containing response columns,
or a data frame of numeric response variables (the latter would not work when directly
using function plot.design
from package graphics)
Specification of selected factors through option select
has been introduced in order to obtain manageable plot sizes. For example,
mosaic plots are most easily readible for up to three or at most four factors.
Main effects plots with too many factors may also be hard to read because of overlapping
labeling. select
can also be used for bringing the factors into a desirable order.
select
can be
a vector of integers with position numbers of experimental factors,
a character vector of factor letters,
or a character vector of factor names for factors to be selected for plotting;
in case of ambiguity, factor names take precedence over factor letters.
The following choices are of interest for creating mosaic plots of the design
factors; any response data will be ignored.
select
can be
a list of numeric vectors (all of equal length) specifying the tuples to be plotted
(a length one list (insted of the numeric vector itself) allows to plot
the design table as a mosaic plot instead of showing a main effects
plot, if the design has responses)
one of the special character strings "all2"
, "all3"
or "all4"
for obtaining mosaic plots of all pairs, triples or quadruples of (a selection of) factors
(see Details section),
a list with a numeric vector with position numbers of experimental factors as the first
and one of the above special character strings as the second element for requesting all
tuples of a subset of the factors,
or a list with a single factor position number as the first and one of the above special
character strings as the second element for requesting all tuples that include
the specified single factor,
or any of the character strings "complete"
, "worst"
, "worst.rel"
,
"worst.parft"
or "worst.parftdf"
for automatic selection of the projections with the worst confounding to be plotted
(see Details section)
a number between 0 and 1 indicating which proportion of
worst cases to plot in case select=worst
or select=worst.rel
is to be plotted (see Details section). The default is useful for small
designs only. For large designs, reduce this number !
a logical;
default behavior if ask=NULL
:
ask
is set to TRUE
if multiple plots are requested and
the current graphics device is interactive
(or none is open but be the next to be opened device is interactive) and
FALSE
otherwise
further arguments to functions plot
,
mosaic
, or the function plot.design
from package graphics;
For experts, option sub
with the special settings "GR"
, "A"
,"rA"
,
"sumPARFT"
or "sumPARFTdf"
can be used to create sub titles that display the generalized resolution,
absolute or relative word lengths (see generalized.word.length
).
All other specifications for sub
should work as expected.
Ulrike Groemping
Items of class design
are data frames with attributes,
that have been created for conducting experiments. Apart from the plot method
documented here, separate files document the methods formula.design
,
lm.design
, and further methods
.
The method for plot
calls the method available in package graphics
(see plot.design
) wherever this makes sense (x
not of class design
,
x
of class design
but not following the class design
structure
defined in package DoE.base,
and x
a design with all factors being R-factors and at least one response available).
Function plot.design
from package graphics is not
an adequate choice for designs without responses or designs with experimental factors
that are not R-factors.
For designs with all factors being R-factors and no response defined (e.g. a freshly-created
design from function oa.design
), function plot.design
creates a mosaic plot of
the frequency table of the design, which may be quite useful to understand the structure
for designs with relatively few factors (cf. example below; function plot.design
calls
function mosaic
for this purpose). It will generally be necessary to specify the select
argument, if the design is not very small. If select
is not specified although there are more than four factors, select=1:4
is chosen as the default.
For designs with at least one experimental factor that is not an R-factor, function
plot.design
calls function plot.data.frame
in order
to create a scatter plot matrix.
Currently, there is no good method for plotting designs with mixed qualitative
and quantitative factors.
If option select
is set to "all2"
, "all3"
or "all4"
,
or a list with a numeric vector as its first element and one of these as the second element,
or with select
as any of "complete"
, "worst"
, "worst.rel"
,
"worst.parft"
or "worst.parftdf"
,
response variables are ignored, and mosaic plots are created.
These requests usually ask for several plots; note that the plots are
created one after the other; with an interactive graphics device, the default is that they overwrite each other
after a user confirmation for the next plot, which allows users to visually inspect them one at a time;
under Windows, the plotting series can be aborted using the Esc
-key.
With non-interactive graphics devices,
the default is ask=FALSE
(e.g. for storing all the plots
in a multi-page file, see examples).
If option select
is any of "all2"
, "all3"
or "all4"
,
mosaic plots of all pairs, triples or quadruples of factors are created as specified.
Note that "all2"
is interesting for non-orthogonal designs only, e.g. ones created by function Dopt.design
.
If option select
is set to "complete"
, "worst"
"worst.rel"
,
"worst.parft"
or "worst.parftdf"
,
the worst case tuples to be displayed are selected by function tupleSel
.
Groemping, U (2014) Mosaic plots are useful for visualizing low order projections of factorial designs. To appear in The American Statistician https://www.tandfonline.com/action/showAxaArticles?journalCode=utas20.
See also the following functions known to produce objects of class
design
: FrF2
, pb
, fac.design
, oa.design
,
and function plot.design
from package graphics;
a method for function lm
is described in the separate help file
lm.design
.
#### Examples for plotting designs
oa12 <- oa.design(nlevels=c(2,2,6))
## plotting a design without response (uses function mosaic from package vcd)
plot(oa12)
## equivalent to mosaic(~A+B+C, oa12)
## alternative order: mosaic(~C+A+B, oa12)
plot(oa12, select=c(3,1,2))
## using the select function: the plots show that the projection for factors
## C, D and E (columns 3, 14 and 15 of the array) is a full factorial,
## while A, D and E (columns 1, 14, and 15 of the array) do not occur in
## all combinations
plan <- oa.design(L24.2.13.3.1.4.1,nlevels=c(2,2,2,3,4))
plot(plan, select=c("E","D","A"))
plot(plan, select=c("E","D","C"))
if (FALSE) {
plot(plan, select="all3")
plot(plan, select=list(c(1,3,4,5), "all3"))
## use the specialist version of option sub
plot(plan, select=list(c(1,3,4,5), "all3"), sub="A")
## create a file with mosaic plots of all 3-factor projections
pdf(file="exampleplots.pdf")
plot(plan, select="all3", main="Design from L24.2.13.3.1.4.1 in default column order)")
plot(plan, select="worst", selprop=0.3, sub="A")
dev.off()
## the file exampleplots.pdf is now available within the current working
## directory
}
## plotting a design with response
y=rnorm(12)
plot(oa12, y)
## plot design with a response included
oa12.r <- add.response(oa12,y)
plot(oa12.r)
## plotting a numeric design (with or without response,
## does not make statistical sense here, for demo only)
noa12 <- qua.design(oa12, quantitative="all")
plot(noa12, y, main="Scatter Plot Matrix")
Run the code above in your browser using DataLab