View source: R/emmeans_power.R
emmeans_power  R Documentation 
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).
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"), ... )
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. 
Note that calculation of power is based on the F and tratio assuming
twosided testing. Thus, the function does not honor adjustments of the
testing procedure due to either onesided testing (or twoone sided tests)
or corrections for multiple comparisons via the p.adjust
option in
emmeans
.
Power for onesided tests can be calculated, if the means of the simulated
dataset are consistent with the directional hypothesis, by doubling
alpha_level
. Similarly, power for Bonferronicorrected contrasts can be
calculated by adjusting alpha_level
accordingly (see examples).
...
Other arguments passed onto the function
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/1pes) and the noncentrality parameter is = f^2*df(error)
"dataframe"
A dataframe of the simulation result.
"aov_result"
aov
object returned from aov_car
.
"aov_result"
emmeans
object returned from emmeans
.
"main_result"
The power analysis results for ANOVA level effects.
"pc_results"
The power analysis results for the pairwise (ttest) comparisons.
"emm_results"
The power analysis results of the pairwise comparison results.
"manova_results"
Default is "NULL". If a withinsubjects factor is included, then the power of the multivariate (i.e. MANOVA) analyses will be provided.
"alpha_level"
The alpha level, significance cutoff, 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
Frederik Aust
Hoenig, J. M., & Heisey, D. M. (2001). The Abuse of Power. The American Statistician, 55(1), 19–24. https://doi.org/10.1198/000313001300339897
## 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 Bonferroniadjusted 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 onesided 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 followup 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.