# NOT RUN {
# Set up a within design with 2 factors, each with 2 levels
design_result <- ANOVA_design(design = "2w*2w",
n = 40, mu = c(1, 0, 1, 0),
sd = 2, r = 0.8,
labelnames = c("condition", "cheerful",
"sad", "voice", "human", "robot"))
exact_result <- ANOVA_exact(design_result,
alpha_level = 0.05, verbose = FALSE,
emm = TRUE, contrast_type = "pairwise")
# Power for pairwise contrasts
exact_result$emm_results
# Corresponding emmeans contrasts
exact_result$emmeans$contrasts
# Manually recalculate power
emmeans_power(exact_result$emmeans$contrasts,
alpha_level = 0.05)
# Calculate power for Bonferroni-adjusted pairwise comparisons
n_contrasts <- nrow(as.data.frame(exact_result$emmeans$contrasts))
emmeans_power(exact_result$emmeans$contrasts,
alpha_level = 0.05 / n_contrasts)
# Calculate power for one-sided custom contrasts
exact_result$emmeans$emmeans
custom_contrast <- contrast(exact_result$emmeans$emmeans,
list(robot_vs_sad_human = c(0, 1, -0.5, -0.5)))
emmeans_power(custom_contrast,
alpha_level = 0.05 * 2)
# Calculate power for follow-up ANOVA
follow_up <- joint_tests(exact_result$emmeans$emmeans,
by = "condition")
emmeans_power(follow_up,
alpha_level = 0.05 / 2)
emmeans_power(emmeans(exact_result$emmeans$emmeans,
pairwise ~ voice | condition)$contrasts,
alpha_level = 0.05 / 2)
# }
Run the code above in your browser using DataLab