Learn R Programming

PowRPriori (version 0.1.2)

fixed_effects_from_average_outcome: Calculate Fixed-Effects Coefficients from Mean Outcomes

Description

A user-friendly helper function to translate expected outcomes (e.g., cell means, probabilities, or rates) into the regression coefficients required by the simulation. This is often more intuitive than specifying coefficients directly.

Usage

fixed_effects_from_average_outcome(formula, outcome, family = "gaussian")

Value

A named list of coefficients suitable for the fixed_effects

argument in power_sim().

Arguments

formula

The fixed-effects part of the model formula (e.g., y ~ group * time).

outcome

A data frame containing columns for all predictor variables and exactly one column for the expected outcome values.

family

The model family ("gaussian", "binomial", "poisson"). The outcome values should be means for gaussian, probabilities (0-1) for binomial, and non-negative rates/counts for poisson.

Examples

Run this code
outcome_means <- tidyr::expand_grid(
  group = c("Control", "Treatment"),
  time = c("pre", "post")
)
outcome_means$mean <- c(10, 10, 12, 15) # Specify expected means

fixed_effects_from_average_outcome(
  formula = score ~ group * time,
  outcome = outcome_means
)

Run the code above in your browser using DataLab