emmeans_power {Superpower} | R Documentation |
Compute power for emmeans contrasts
Description
Computes power based on t value and degrees of freedom for contrasts. Do not use to calculate "observed power" for empirical datasets (Hoenig & Heisey, 2001).
Usage
emmeans_power(x, ...)
## S3 method for class 'emmGrid'
emmeans_power(x, ...)
## S3 method for class 'summary_em'
emmeans_power(x, ...)
## S3 method for class 'data.frame'
emmeans_power(
x,
alpha_level = Superpower_options("alpha_level"),
liberal_lambda = Superpower_options("liberal_lambda"),
...
)
Arguments
x |
|
... |
Other arguments passed to the function if object is not already a |
alpha_level |
Alpha level used to determine statistical significance |
liberal_lambda |
Logical indicator of whether to use the liberal (cohen_f^2\*(num_df+den_df)) or conservative (cohen_f^2\*den_df) calculation of the noncentrality (lambda) parameter estimate. Default is FALSE. |
Details
Note that calculation of power is based on the F- and t-ratio assuming
two-sided testing. Thus, the function does not honor adjustments of the
testing procedure due to either one-sided testing (or two-one sided tests)
or corrections for multiple comparisons via the p.adjust
option in
emmeans
.
Power for one-sided tests can be calculated, if the means of the simulated
dataset are consistent with the directional hypothesis, by doubling
alpha_level
. Similarly, power for Bonferroni-corrected contrasts can be
calculated by adjusting alpha_level
accordingly (see examples).
...
Other arguments passed onto the function
Value
Returns dataframe with simulation data (power and effect sizes!), anova results and simple effect results, plot of exact data, and alpha_level. Note: Cohen's f = sqrt(pes/1-pes) and the noncentrality parameter is = f^2*df(error)
"dataframe"
A dataframe of the simulation result.
"aov_result"
aov
object returned fromaov_car
."aov_result"
emmeans
object returned fromemmeans
."main_result"
The power analysis results for ANOVA level effects.
"pc_results"
The power analysis results for the pairwise (t-test) comparisons.
"emm_results"
The power analysis results of the pairwise comparison results.
"manova_results"
Default is "NULL". If a within-subjects factor is included, then the power of the multivariate (i.e. MANOVA) analyses will be provided.
"alpha_level"
The alpha level, significance cut-off, used for the power analysis.
"method"
Record of the function used to produce the simulation
"plot"
A plot of the dataframe from the simulation; should closely match the meansplot in
ANOVA_design
Author(s)
Frederik Aust
References
Hoenig, J. M., & Heisey, D. M. (2001). The Abuse of Power. The American Statistician, 55(1), 19–24. https://doi.org/10.1198/000313001300339897
Examples
## 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)
## End(Not run)