# A 2 by 3 factorial ANCOVA. The conclusion needs both main effects to hold,
# so the design is planned against their composite. The covariate explains
# 25 percent of the within-cell variance (one covariate).
ss_power_composite_factorial_ancova(
factor_levels = c(2, 3),
effects = list(list(factors = 1, f = 0.25),
list(factors = 2, f = 0.20)),
covariate_R2 = 0.25, n_covariates = 1,
desired_power = 0.80)
# Realized composite power at 40 per cell for a main effect and the
# interaction of a 2 by 2 design, effect sizes given as partial eta squared.
ss_power_composite_factorial_ancova(
factor_levels = c(2, 2),
effects = list(list(factors = 1, partial_eta_squared = 0.06),
list(factors = c(1, 2), partial_eta_squared = 0.04)),
n_per_cell = 40)
# Naming one effect reproduces the single-effect planner exactly.
ss_power_composite_factorial_ancova(
factor_levels = c(2, 3), effects = list(list(factors = 2, f = 0.25)),
n_per_cell = 20)
ss_power_factorial_anova(factor_levels = c(2, 3), effect_indices = 2,
f = 0.25, n_per_cell = 20)
# The composite is not the product of the marginal powers. The tests share
# one error estimate, so they are positively dependent and the composite is
# the larger of the two.
plan <- ss_power_composite_factorial_ancova(
factor_levels = c(2, 2, 3),
effects = list(list(factors = 1, f = 0.30, label = "A"),
list(factors = c(1, 3), f = 0.25, label = "AxC")),
n_per_cell = 15)
plan$value[plan$term == "composite_power"]
prod(plan$value[plan$term %in% c("power_A", "power_AxC")])
# A one-row broom summary of the plan.
generics::tidy(ss_power_composite_factorial_ancova(
factor_levels = c(2, 3),
effects = list(list(factors = 1, f = 0.25),
list(factors = 2, f = 0.20)),
desired_power = 0.80))
# The figure of the purported population values, annotated with the power a
# given sample size delivers.
plot(ss_power_composite_factorial_ancova(
factor_levels = c(2, 3),
effects = list(list(factors = 1, f = 0.25),
list(factors = 2, f = 0.20)),
n_per_cell = 30))
# The effects can instead be stated as a full pattern of population cell means
# with a common within-cell SD. Rows are the 2-level factor, columns the
# 3-level factor. plot() then draws the mean pattern itself.
cell_means <- matrix(c(10, 12, 11,
13, 12, 16), nrow = 2, byrow = TRUE)
fit <- ss_power_composite_factorial_ancova(
factor_levels = c(2, 3), means = cell_means, sigma = 4,
effects = list(list(factors = 1, label = "A"),
list(factors = 2, label = "B")),
n_per_cell = 30)
fit
plot(fit)
Run the code above in your browser using DataLab