fixed.factor {designr}R Documentation

Fixed factors

Description

This function creates an instance of fixedFactor to be used in a factorDesign. Fixed factors typically relate to (quasi-)experimental factors such as experimental conditions/manipulations, subject/item characteristics ect.

Usage

fixed.factor(
  name,
  levels,
  blocked = FALSE,
  character_as_factor = TRUE,
  is_ordered = FALSE,
  block_name = "%1$s.%2$d",
  groups = character(0),
  replications = 1L,
  assign = "latin.square",
  ...
)

Arguments

name

Name of the fixed factor.

levels

If not grouped, a vector of factor levels. Any atomic data type (character, logical, numeric, integer) can be used. If grouped, this should be a named list with each entry being a vector (as described before) and its name being a value of the grouping factor(s). If grouped within several factors, i.e. an interaction, the values constituting the names should be concatenated by colons (:), e.g. list(`f1l1:f2l1`=1:2, `f1l2:f2l1`=3:4, ...). If for any group there are no levels specified, a warning will be issued and NA will be assigned as the value for this factor. If this is intended and the warning should be suppressed, please explicitly assign NA as the value for that group, e.g. list(`f1l1:f2l1`=1:2, `f1l2:f2l1`=NA, ...).

blocked

Set this to TRUE if the levels of this factor are blocked. In that case, a factor is created whose factor levels are different sequences of the levels specified in the function call.

character_as_factor

If this is TRUE, character vectors passed in levels are automatically converted to a factor type.

is_ordered

Is this an ordered factor?

block_name

If blocked = TRUE, by default, there is not only a design matrix column created that contains the complete sequence of block levels but also a column for each position of the sequence with its assigned level. You may specify a different naming pattern using sprintf naming conventions. The first argument passed is the factor name and the second argument is the sequence position (starting at 1). The default column names will be factor.1, factor.2, etc. If NULL, no additional block columns are created.

groups

Names of fixed factors in which to nest this fixed factor (see *Nesting fixed factors*).

replications

Either a single integer or an integer vector of the same length as levels that is used to determine how many times each factor level should be repeated.

assign

If blocked = TRUE, you may specify a different method of rotating levels. The default if 'latin.square' but 'permutations', 'williams', and 'random.order' are also available.

...

more data to save as attributes

Value

An instance of fixedFactor.

Nesting Fixed Factors

If groups is used, the function will attempt to nest levels of the newly created factor within levels/interactions of the specified grouping factors. Note that nesting of fixed effects is only allowed within other fixed effects combinations but not within random effects. For each combination of the grouping factors, e.g. each group, you should specify an individual vector of levels (see above). If you fail to supply levels for any group, NAs will be assigned. This could result in unpredicted behavior when more factors are added. If you know what you are doing and would like to suppress the warning, please explicitly specify NA as the (only) value to assign to that group. At any rate, it is highly recommended to run sanity checks on the balancedness of the design if you are nesting fixed factors!

See Also

random.factor

Examples

fixed.factor("correct", levels=c(TRUE, FALSE))
fixed.factor("age", levels=c("child", "youth", "adult"))
fixed.factor("order", levels=c("task1", "task2", "task3"), blocked = TRUE, assign="latin.square")


[Package designr version 0.1.12 Index]