| fixed_effects_from_average_outcome | R Documentation |
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.
fixed_effects_from_average_outcome(
formula,
outcome,
center = TRUE,
family = "gaussian"
)
formula |
The fixed-effects part of the model formula (e.g., |
outcome |
A data frame containing columns for all predictor variables and exactly one column for the expected outcome values. |
center |
If |
family |
The model family ( |
By default, this function applies effect coding (orthogonal contrasts) to the
predictors in your design (center = TRUE). Because the predictors are
treated as being mean-centered this way, the intercept of the calculated
coefficients represents the grand mean of your specified outcomes.
Importantly, setting center = TRUE also adds an attribute to the resulting
coefficient list. When the coefficients are later passed to power_sim(),
the simulation engine will detect this attribute and automatically apply the corresponding
mean-centering to the generated sample data (grand-mean centering for between-subject
variables, and within-cluster / person-mean centering for within-subject variables).
The choices for these respective centering techniques have been made to ensure the most robust
fixed / random effects and power estimates. For more details on the issue of centering, refer to the vignette:
vignette("Workflow-Example", package = "PowRPriori")
A named list of coefficients suitable for the fixed_effects
argument in power_sim().
outcome_means <- tidyr::expand_grid(
group = c("Control", "Treatment"),
time = c("pre", "post")
)
outcome_means$mean <- c(10, 10, 12, 15) # Specify expected means
#Per default, the predictors are effect-coded (centered) here
fixed_effects_from_average_outcome(
formula = score ~ group * time,
outcome = outcome_means
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.