# ANOVA_power: Simulation function used to estimate power In Superpower: Simulation-Based Power Analysis for Factorial Designs

## Description

Simulation function used to estimate power

## Usage

 ``` 1 2 3 4 5 6 7 8 9 10 11 12 13 14``` ```ANOVA_power( design_result, alpha_level = Superpower_options("alpha_level"), correction = Superpower_options("correction"), p_adjust = "none", nsims = 1000, seed = NULL, verbose = Superpower_options("verbose"), emm = Superpower_options("emm"), emm_model = Superpower_options("emm_model"), contrast_type = Superpower_options("contrast_type"), emm_p_adjust = "none", emm_comp = NULL ) ```

## Arguments

 `design_result` Output from the ANOVA_design function `alpha_level` Alpha level used to determine statistical significance `correction` Set a correction of violations of sphericity. This can be set to "none", "GG" Greenhouse-Geisser, and "HF" Huynh-Feldt `p_adjust` Correction for multiple comparisons. This will adjust p values for ANOVA/MANOVA level effects; see ?p.adjust for options `nsims` number of simulations to perform `seed` Set seed for reproducible results `verbose` Set to FALSE to not print results (default = TRUE) `emm` Set to FALSE to not perform analysis of estimated marginal means `emm_model` Set model type ("multivariate", or "univariate") for estimated marginal means `contrast_type` Select the type of comparison for the estimated marginal means. Default is pairwise. See ?emmeans::'contrast-methods' for more details on acceptable methods. `emm_p_adjust` Correction for multiple comparisons; default is "none". See ?summary.emmGrid for more details on acceptable methods. `emm_comp` Set the comparisons for estimated marginal means comparisons. This is a factor name (a), combination of factor names (a+b), or for simple effects a | sign is needed (a|b)

## Value

Returns dataframe with simulation data (p-values and effect sizes), anova results (type 3 sums of squares) and simple effect results, and plots of p-value distribution.

`"sim_data"`

Output from every iteration of the simulation

`"main_result"`

The power analysis results for ANOVA effects.

`"pc_results"`

The power analysis results for pairwise comparisons.

`"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.

`"emm_results"`

The power analysis results of the estimated marginal means.

`"plot1"`

Distribution of p-values from the ANOVA results.

`"plot2"`

Distribution of p-values from the pairwise comparisons results.

`"correction"`

The correction for sphericity applied to the simulation results.

`"p_adjust"`

The p-value adjustment applied to the simulation results for ANOVA/MANOVA omnibus tests and t-tests.

`"emm_p_adjust"`

The p-value adjustment applied to the simulation results for the estimated marginal means.

`"nsims"`

The number of simulations run.

`"alpha_level"`

The alpha level, significance cut-off, used for the power analysis.

`"method"`

Record of the function used to produce the simulation

## Examples

 ``` 1 2 3 4 5 6 7 8 9 10 11 12 13``` ```## Not run: ## Set up a within design with 2 factors, each with 2 levels, ## with correlation between observations of 0.8, ## 40 participants (who do all conditions), and standard deviation of 2 ## with a mean pattern of 1, 0, 1, 0, conditions labeled 'condition' and ## 'voice', with names for levels of "cheerful", "sad", amd "human", "robot" 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")) power_result <- ANOVA_power(design_result, alpha_level = 0.05, p_adjust = "none", seed = 2019, nsims = 10) ## End(Not run) ```

### Example output

```Registered S3 methods overwritten by 'lme4':
method                          from
cooks.distance.influence.merMod car
influence.merMod                car
dfbeta.influence.merMod         car
dfbetas.influence.merMod        car
Power and Effect sizes for ANOVA tests
power effect_size
anova_condition          10     0.03039
anova_voice             100     0.53424
anova_condition:voice    10     0.03689

Power and Effect sizes for pairwise comparisons (t-tests)
power
p_condition_cheerful_voice_human_condition_cheerful_voice_robot   100
effect_size
p_condition_cheerful_voice_human_condition_cheerful_voice_robot     -0.7714