These functions return useful summaries of a factor design, including the design matrix itself as well as other parameters and a list of random factors as experimental units.
output.design(
design,
group_by = NULL,
order_by = NULL,
randomize = FALSE,
rename_random = TRUE
)design.formula(
design,
contrasts = NULL,
expand_contrasts = !missing(contrasts),
interactions = TRUE,
intercepts = TRUE,
response = "dv",
env = parent.frame()
)
design.units(design, rename_random = TRUE, include_interactions = FALSE)
design.codes(
design,
group_by = NULL,
order_by = names(random.factors(design, include_interactions = FALSE)),
randomize = FALSE,
rename_random = TRUE
)
output.design
returns a list containing all output summaries, including the following named entities:
codes
Either a tibble
with all experimental codes or a list of tibble
s of experimental codes. The list entries are matched to the rows of $groups
.
groups
If grouped, contains a tibble in which each row represents an output group, matched to the entries in $codes. If not grouped, this is NULL
.
ordered
If ordered, contains a vector of order criteria. If not ordered, this is NULL
.
randomized
Value of randomized
.
units
A list of random factors and their levels for this design as tibbles. Empty list if no random factors in the design.
formulas
A list of possible model formulas for use with functions such as lm()
and lmer()
.
The functions design.codes
, design.formula
and design.units
only return the values of the fields codes
(a tibble
or list or tibble
s of experimental codes), formulas
(a list of model formulas), and units
(a list of random factors and their levels), respectively.
The factorDesign
object to summarize.
If not NULL
, the design matrix is grouped by these factors. Factors must be valid columns of the design matrix. If used, $codes
will be a list matched to the entries in $groups
.
If not NULL
, output within each output group is ordered by these columns.
After ordering, remaining rows in the same order rank are randomly shuffled.
Should random factor levels be renamed? If TRUE
, levels are renamed as strings composed of the factor name and factor level (e.g., Subj01, Subj02, ...). FALSE
disables renaming of random factor levels. Alternatively, you may provide a function which should accept the vectorized ID (integer) as a first argument and the name (single character value) of the random factor as second argument or ignore it. Functions such as as.double
or as.integer
*are* possible because they ignore the second argument and only convert the ID.
The contrasts to override (NULL
if none to override)
If TRUE
, factors with more than one contrast are replaced by so many contrasts, i.e. the result contains the names of the individual contrasts, not of the factors.
Should fixed effects be additive or interactive?
Should an intercept be included?
The left-hand side of the equation. Typically, this is just the response/dependent variable.
The environment in which to embed the formula
Whether to include random factor interactions (i.e., counterbalancing factors) in the output
design.formula()
: Retrieve only the model formulas suitable for the design
design.units()
: Retrieve only the experimental units of a design
design.codes()
: Retrieve only the codes of planned observations of an experimental design
The function design.units
returns the experimental units of the design. Those are defined by random factors and their levels. See units
return value below.
design.codes
returns a dataframe or tibble
of all planned observations including each observation's experimental codes, i.e. fixed and random factor levels. If you group the output, a list is returned. See codes
return value below.
design.formula
returns a list of formulas suitable for regression analysis. Currently, formulas for lm
and lme4
are returned. See formulas
entry,
design.formula
for more options generating model formulae other than the suggested default ones in the summary.
des <- fixed.factor("Factor1", c("1A","1B")) +
fixed.factor("Factor2", c("2A","2B")) +
random.factor("Subject", c("Factor1"))
output.design(des)
design.codes(des)
design.units(des)
design.formula(des)
Run the code above in your browser using DataLab