Learn R Programming

PowRPriori (version 0.1.2)

get_random_effects_structure: 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")

Value

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

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 if sd_resid should be included in the template.

Examples

Run this code
design <- define_design(
  id = "subject",
  within = list(time = c("pre", "post"))
)
get_random_effects_structure(y ~ time + (time|subject), design)

Run the code above in your browser using DataLab