fac.design | R Documentation |

Function for creating full factorial designs with arbitrary numbers of levels, and potentially with blocking

```
fac.design(nlevels=NULL, nfactors=NULL, factor.names = NULL,
replications=1, repeat.only = FALSE, randomize=TRUE, seed=NULL,
blocks=1, block.gen=NULL, block.name="Blocks", bbreps=replications,
wbreps=1, block.old.behavior=FALSE)
```

`nlevels` |
number(s) of levels, vector with |

`nfactors` |
number of factors, can be omitted if obvious from entries |

`factor.names` |
if |

`replications` |
positive integer number. Default 1 (i.e. each row just once).
If larger, each design run is executed replication times.
If Otherwise (default), the full experiment is first carried out once, then for the second replication and so forth. In case of randomization, each such blocks is randomized separately. In this case, replication variance is more likely suitable for usage as error variance (unless e.g. the same parts are used for replication runs although build variation is important). |

`repeat.only` |
logical, relevant only if replications > 1. If |

`randomize` |
logical. If |

`seed` |
integer seed for the random number generator |

`blocks` |
is the number of blocks into which the experiment is to be subdivided; If the experiment is randomized, randomization happens within blocks. |

`block.gen` |
provides block generating information. There must be a row for each prime number into which Rows for a p-level contributor to the block factor (p a prime) consist of entries 0 to p-1 only. |

`block.name` |
name of the block factor, default “Blocks” |

`bbreps` |
between block replications; these are always taken as genuine replications,
not repeat runs; default: equal to |

`wbreps` |
within block replications; whether or not these are taken as genuine replications
depends on the setting of |

`block.old.behavior` |
logical that can be used to activate the old (prior to version 0.27) behavior of blocking full factorial designs; the new behavior is the default, as it often creates designs with less severe confounding |

`fac.design`

creates full factorial designs, i.e. the number of runs is the
product of all numbers of levels.

It is possible to subdivide the design into blocks (one hierarchy level only)
by specifying an appropriate number of blocks. The method used is a generalization of
the one implemented in function `conf.design`

for
symmetric factorials (i.e. factorials with all factors at the same prime number
of levels) and related to the method described in Collings (1984, 1989);
function `conf.set`

from
package conf.design is used for checking the confounding
consequences of blocking.

Note that the number of blocks must
be compatible with the factor levels; it must factor into primes that occur with
high enough frequency among the pseudo-factors of the design.
This statement is now explained by an example: Consider a design with five factors at
2, 2, 3, 3, 6 levels. The 6-level factor can be thought of as consisting of
two pseudo-factors, a 2-level and a 3-level pseudo-factor, according to the
factorization of the number 6 into the two primes 2 and 3. It is possible

to obtain two blocks by confounding the two-factor interaction of the
two 2-level factors and the 2-level pseudo-factor of the 6-level factor,

or to obtain three blocks by confounding the blocking factor with the
three-factor interaction of the two three-level factors and the three-level
pseudo-factor of the 6-level factor,

or to get six blocks, by doing both simultaneously.

It is also possible to obtain 4 or 9 or even 36 blocks, if one is happy to
confound two-factor interactions with blocks. The 36 blocks are the product
of the 4 blocks from the 2-level portion with the nine blocks from the 3-level
portion. For each portion separately, there is a lookup-table for blocking
possibilities (`block.catlg`

), for up to 128 blocks in 256 runs,
or up to 81 blocks in 243 runs.

5 blocks cannot be done for the above example design. Even if there were one additional factor at 5 levels, it would still not be possible to do a number of blocks with divisor 5, because this would confound the main effect of a factor with blocks and would thus generate an error.

For any primes apart from 2 or 3, only one at a time can be handled automatically.
For example, if a design has three 5-level factors, it can be automatically subdivided
into 5 blocks by the option `blocks=5`

.
It is also possible to run the design in 25 blocks; however, as 25=5*5, this cannot be done
automatically but has to be requested by specifying the `block.gen`

option
in addition to the `blocks`

option
(in this case, `block.gen=rbind(c(1,0,1),c(1,1,0))`

would do the job).

`fac.design`

returns a data frame of S3 class `design`

with attributes attached.

The experimental factors are all stored as R factors.

For factors with 2 levels, `contr.FrF2`

contrasts (-1 / +1) are used.

For factors with more than 2 numerical levels, polynomial contrasts are used
(i.e. analyses will per default use orthogonal polynomials).

For factors with more than 2 categorical levels, the default contrasts are used.

For changing the contrasts, use function `change.contr`

.

The `design.info`

attribute of the data frame has the following elements:

- type
character string “full factorial” or “full factorial.blocked”

- nruns
number of runs (replications are not counted)

- nfactors
number of factors

- nlevels
vector with number of levels for each factor

- factor.names
list named with (treatment) factor names and containing as entries vectors with coded factor levels

- nblocks
for designs of type

`full factorial.blocked`

only;

number of blocks- block.gen
for designs of type

`full factorial.blocked`

only;

matrix the rows of which are the coefficients of the linear combinations that create block columns from of pseudo factors- blocksize
for designs of type

`full factorial.blocked`

only;

size of each block (without consideration of`wbreps`

)- replication
option setting in call to

`FrF2`

- repeat.only
option setting in call to

`FrF2`

- bbreps
for designs of type

`FrF2.blocked`

only; number of between block replications- wbreps
for designs of type

`FrF2.blocked`

only; number of within block replications;

`repeat.only`

indicates whether these are replications or repetitions only- randomize
option setting in call to

`FrF2`

- seed
option setting in call to

`FrF2`

- creator
call to function FrF2 (or stored menu settings, if the function has been called via the R commander plugin RcmdrPlugin.DoE)

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`

.

This package is still under development. Suggestions and bug reports are welcome.

Ulrike Groemping

Collings, B.J. (1984). Generating the intrablock and interblock subgroups for
confounding in general factorial experiments. *Annals of Statistics* **12**,
1500–1509.

Collings, B.J. (1989). Quick confounding. *Technometrics* **31**,
107–110.

See also `FrF2`

, `oa.design`

, `pb`

, `conf.set`

,
`block.catlg`

```
## only specify level combination
fac.design(nlevels=c(4,3,3,2))
## design requested via factor.names
fac.design(factor.names=list(one=c("a","b","c"), two=c(125,275),
three=c("old","new"), four=c(-1,1), five=c("min","medium","max")))
## design requested via character factor.names and nlevels
## (with a little German lesson for one two three)
fac.design(factor.names=c("eins","zwei","drei"),nlevels=c(2,3,2))
### blocking designs
fac.design(nlevels=c(2,2,3,3,6), blocks=6, seed=12345)
## the same design, now unnecessarily constructed via option block.gen
## preparation: look at the numbers of levels of pseudo factors
## (in this order)
unlist(factorize(c(2,2,3,3,6)))
## or, for more annotation, factorize the unblocked design
factorize(fac.design(nlevels=c(2,2,3,3,6)))
## positions 1 2 5 are 2-level pseudo factors
## positions 3 4 6 are 4-level pseudo factors
## blocking with highest possible interactions
G <- rbind(two=c(1,1,0,0,1,0),three=c(0,0,1,1,0,1))
plan.6blocks <- fac.design(nlevels=c(2,2,3,3,6), blocks=6, block.gen=G, seed=12345)
plan.6blocks
## two blocks, default design, but unnecessarily constructed via block.gen
fac.design(nlevels=c(2,2,3,3,6), blocks=2, block.gen=c(1,1,0,0,1,0), seed=12345)
## three blocks, default design, but unnecessarily constructed via block.gen
fac.design(nlevels=c(2,2,3,3,6), blocks=3, block.gen=c(0,0,1,1,0,1), seed=12345)
## nine blocks
## confounding two-factor interactions cannot be avoided
## there are warnings to that effect
G <- rbind(CD=c(0,0,1,1,0,0),CE2=c(0,0,1,0,0,1))
plan.9blocks <- fac.design(nlevels=c(2,2,3,3,6), blocks=9, block.gen=G, seed=12345)
## further automatic designs, not run for shortening run time
## Not run:
fac.design(nlevels=c(2,2,3,3,6), blocks=4, seed=12345)
fac.design(nlevels=c(2,2,3,3,6), blocks=9, seed=12345)
fac.design(nlevels=c(2,2,3,3,6), blocks=36, seed=12345)
fac.design(nlevels=c(3,5,6,10), blocks=15, seed=12345)
## End(Not run)
## independently check aliasing
## model with block main effects and all two-factor interactions
## 6 factors: not aliased
summary(plan.6blocks)
alias(lm(1:nrow(plan.6blocks)~Blocks+(A+B+C+D+E)^2,plan.6blocks))
## 9 factors: aliased
summary(plan.9blocks)
alias(lm(1:nrow(plan.9blocks)~Blocks+(A+B+C+D+E)^2,plan.9blocks))
```

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.