2^k factorial-design analysis with main effects + interactions
Source:R/mrm_design.R
mrm_factorial_2k.RdReturns main effects (difference of means at +1 vs -1 per factor), all interaction effects, and half-normal-plot coordinates for Daniel's method (which lets the user separate active effects from a null half-normal line on the same axes).
Value
Named list with main_effects, interaction_effects, half_normal_coords (data.frame), n, k, interpretation.
Examples
# 2^3 full factorial: 8 runs, factors A, B, C in {-1, +1}.
set.seed(2026)
lvl <- c(-1, 1)
df <- expand.grid(A = lvl, B = lvl, C = lvl)
df$y <- 10 + 2 * df$A + 1.5 * df$B + 0.5 * df$A * df$B + rnorm(8, 0, 0.2)
res <- mrm_factorial_2k(df,
response_col = "y",
factor_cols = c("A", "B", "C")
)
res$main_effects
#> $A
#> [1] 3.802065
#>
#> $B
#> [1] 3.102053
#>
#> $C
#> [1] -0.221669
#>
res$interaction_effects
#> $`A x B`
#> [1] 1.147038
#>
#> $`A x C`
#> [1] -0.015508
#>
#> $`B x C`
#> [1] 0.040693
#>
#> $`A x B x C`
#> [1] 0.009409
#>