Skip to contents

Projects a supplied relative pattern (or uses the documented linear/Kronecker default) for one ANOVA term and scales it so an exact reference dataset has the requested partial eta squared under the supplied balanced design assumptions.

Usage

design_term_means(
  design,
  term,
  target_pes,
  n,
  sd = 1,
  r = 0.5,
  gpower = FALSE,
  ss_type = "III",
  means_pattern = NULL
)

Arguments

design

An anovapowersim_design_spec from balanced_anova_design().

term

Character scalar naming the ANOVA term to target. Interaction terms are order-insensitive.

target_pes

Target partial eta squared.

n

Sample size per between-subject cell. For pure within designs, this is the total sample size.

sd

Common outcome standard deviation.

r

Compound-symmetric correlation among within-subject cells.

gpower

Logical; if TRUE, calibrate to the GPower-style noncentrality convention lambda = total_n * f^2 (as in the "Cohen (1988)" option for within-subjects designs in GPower). G*Power's estimates can differ from target_pes, especially for small samples or terms with more degrees of freedom; a warning is issued when gpower = TRUE. The default gpower = FALSE is recommended.

ss_type

Sums-of-squares type for the tested ANOVA term. "III" is the default for order-invariant tests in unbalanced designs. Use "I" to reproduce sequential stats::aov() tests.

means_pattern

Optional relative mean shape from means_pattern(). Sparse values are projected onto term before calibration. If NULL, the deterministic linear/Kronecker default is used.

Value

A numeric matrix of cell means, with rows indexing between cells and columns indexing within cells.

Covariance limitation

This manual helper does not accept within_covariance() specifications. Calibration always uses the compound-symmetric covariance defined by sd and r. Consequently, its calibrated means can differ from those used by power_curve(), power_n(), or power_achieved() with a custom covariance, because the covariance affects the reference residual sum of squares and therefore the mean scale factor.

Examples

d <- balanced_anova_design(between = c(group = 2), within = c(time = 2))
design_term_means(d, term = "group:time", target_pes = 0.2, n = 20)
#>            [,1]       [,2]
#> [1,]  0.2436699 -0.2436699
#> [2,] -0.2436699  0.2436699