This function generates cartesian products of two or more experimental designs.
cross.design(design1, design2, ..., randomize = TRUE, seed=NULL)
Function cross.design
returns a simple data frame without design
information, if design1
is not of class design
.
Otherwise, the value is a data frame of class design
with type “crossed” and the following extraordinary elements:
vector of run numbers of individual designs
vector of numbers of factors of individual designs
vector of types of individual designs
vector of logicals (randomized or not) of individual desigs
vector of seeds of individual designs
vector of numbers of replications of individual designs
vector of logicals (repeat.only or not) of individual designs
list with the map vectors for component designs of type FrF2.estimable
NULL
(if no oa
type design) or list of column vectors for each design
list with the nlevels
vectors for those component designs that have them
The standard elements are as usual, with randomize
and seed
referring to
the randomization within function cross.design
itself (previous randomizations are shown
under cross.randomize
and cross.seed
).
The nlevels
element of design.info
is available only if it is
available for all designs that have been crossed (otherwise refer to the element cross.nlevels
.
The creator
element of the design.info
attribute consists is a 2-element list
containing
the list original
of all the original creators and
the element modify
that contains the call to cross.design
.
If present, the clear
, ncube
, ncenter
, residual.df
,
origin
, comment
, generating.oa
elements of design.info
are vector-valued.
If present, the generators
element of design.info
is a list of character vectors.
If present, the aliased
and catlg.entry
elements of design.info
are lists of lists.
a data frame of class design
that restricted by certain
criteria (cf. details)
if design1
is not of class design
, crossing will nevertheless work,
but the output object will be a data frame only without any design information;
there is no guaranteed support for this usage
a data frame of class design
with the same restrictions
for design type as for design1
;
can also be a vector if ...
is not used;
cf. details for what is allowed regarding replications
optional further data frames that are to be crossed;
they must be of class design
with the
above-mentioned restrictions for design types;
the last element can also be a vector
logical indicating whether randomization should take place after crossing the designs
integer seed for the random number generator
In R version 3.6.0 and later, the default behavior of function sample
has changed. If you work in a new (i.e., >= 3.6.-0) R version and want to reproduce
a randomized design from an earlier R version (before 3.6.0),
you have to change the RNGkind setting by
RNGkind(sample.kind="Rounding")
before running function cross.design
.
It is recommended to change the setting back to the new recommended way afterwards:
RNGkind(sample.kind="default")
For an example, see the documentation of the example data set VSGFS
.
Since R version 3.6.0, the behavior of function sample
has changed
(correction of a biased previous behavior that should not be relevant for the randomization of designs).
For reproducing a randomized design that was produced with an earlier R version,
please follow the steps described with the argument seed
.
Ulrike Groemping
Crossing is carried out recursively, following the direct.sum
approach
from package conf.design. All but the last designs must fulfill various
criteria (cf. below). The last design to be crossed can also be a vector.
Designs to be crossed must not be a blocked, nor splitplot, nor crossed, folded
or Taguchi parameter design, nor designs in wide format. Furthermore, designs must
not contain responses (checked via the response.names element of design.info
).
If replications are desired, it is recommended to accomodate them in the last
design. Only the last design may have repeat.only
replications. If the
last design has repeat.only
replications and there are also proper replications
in earlier designs, a warning is thrown, but the repeat.only
replications are
nevertheless accomodated; this is experimental and may not yield the expected
results under all circumstances.
See Also param.design
## creating a Taguchi-style inner-outer array design
## with proper randomization
## function param.design would generate such a design with all outer array runs
## for each inner array run conducted in sequence
## alternatively, a split-plot approach can also handle control and noise factor
## designs without necessarily crossing two separate designs
des.control <- oa.design(ID=L18)
des.noise <- oa.design(ID=L4.2.3,nlevels=2,factor.names=c("N1","N2","N3"))
crossed <- cross.design(des.control, des.noise)
crossed
summary(crossed)
Run the code above in your browser using DataLab