# A 2 by 2 design whose conclusion needs a main effect and evidence that the
# covariate slope differs across the first factor. Effect sizes stated
# directly: the main effect (mean), the average covariate effect, and the
# factor 1 by covariate slope heterogeneity.
ss_power_composite_factorial_ancova_het(
factor_levels = c(2, 2),
effects = list(list(type = "mean", factors = 1, f = 0.25),
list(type = "covariate", f = 0.40),
list(type = "slope", factors = 1, f = 0.20)),
desired_power = 0.80)
# The same design from population values: cell means, a covariate-outcome
# correlation per cell (they differ across factor 1, so the slopes do), and a
# common within-cell SD. plot() then draws the per-cell regression lines.
cell_means <- matrix(c(10, 12,
11, 13), nrow = 2, byrow = TRUE)
cell_rho <- matrix(c(0.55, 0.55,
0.15, 0.20), nrow = 2, byrow = TRUE)
fit <- ss_power_composite_factorial_ancova_het(
factor_levels = c(2, 2), means = cell_means, correlations = cell_rho,
sigma = 4, sd_cov = 2,
effects = list(list(type = "mean", factors = 1),
list(type = "covariate"),
list(type = "slope", factors = 1)),
n_per_cell = 40)
fit
plot(fit)
# The one-factor, two-level case is the two-group composite ANCOVA.
ss_power_composite_factorial_ancova_het(
factor_levels = 2,
means = c(-0.25, 0.25), correlations = c(0.1, 0.5), sigma = 1,
effects = list(list(type = "mean", factors = 1),
list(type = "slope", factors = 1)),
n_per_cell = 100)
Run the code above in your browser using DataLab