Skip to contents

Adds a random effect column (prefixed with ".") to the design data frame, with optional grouping for nested random effects.

Usage

add_random_effect(design_df, ..., .nesting = NULL)

Arguments

design_df

A data frame containing the rollout design and any parameters.

...

A single named expression specifying the random effect to add (e.g., u = rnorm(1, 0, 1)).

.nesting

Optional character vector specifying grouping columns for nested random effects (default NULL).

Value

A tibble with the added random effect column.

Examples

df <- tibble::tibble(site = rep(1:2, each = 3))
add_random_effect(df, u = rnorm(1, 0, 1), .nesting = "site")
#> Error in design_df %>% dplyr::group_by(dplyr::across(all_of(.nesting))): could not find function "%>%"