get_random_effects_structure: Get the Expected Random-Effects Structure

View source: R/utils.R

get_random_effects_structureR Documentation

Get the Expected Random-Effects Structure

Description

Analyzes the random effects terms in a model formula and generates a template for the specified random_effects parameters. This helps in specifying the required standard deviations and correlations correctly. By default, this function prints a copy-paste-able code snippet to the console, where the user only needs to fill in placeholders (...) for the values.

Usage

get_random_effects_structure(formula, design, family = "gaussian")

Arguments

formula

An lme4-style model formula (e.g. outcome ~ predictor1 * predictor2 + (1 | id)).

design

A PowRPriori_design object created with define_design().

family

The model family ("gaussian", "binomial", "poisson"). Determines how the residual variance in a design needs to be handled. Defaults to "gaussian".

Value

Invisibly returns a nested list with placeholders, serving as a template for the random_effects argument in power_sim().

Examples

design <- define_design(
  sample_size = list(subject = 20),
  within = list(time = c("pre", "post"))
)
get_random_effects_structure(y ~ time + (time|subject), design, family = "gaussian")

PowRPriori documentation built on May 12, 2026, 5:06 p.m.