Main Effects
This example study is a 2x3x4 ANOVA taken from exercise 8.14, p.397 of Cohen (1988). All of the effect sizes taken from the exercise were converted from Cohen’s f to eta-squared in order to input the numeric equivalent into the calculations. For this example the main effects will be assigned the variable names: main.eff1
, main.eff2
, and main.eff3
.
# Define main effects
main.eff1 <- list(name = "Sex", levels = 2, eta.sq = 0.0099)
main.eff2 <- list(name = "Age", levels = 3, eta.sq = 0.0588)
main.eff3 <- list(name = "Conditions", levels = 4, eta.sq = 0.1506)
Each main effect is defined as a list and takes in three different values:
name
- The name of the treatment effect. This may be either a character string of the treatment name, an abbreviation, or a single character such as “A”.
levels
- The number of levels/groups in the treatment. This is always an integer that is 2 or greater.
eta.sq
- Estimated effect size for the treatment effect. This can be either a numeric value greater than 0 or a character string. Acceptable string values and their numeric equivalents are: “small” (0.01), “med” (0.06), and “large” (0.14).
Note: If the effect size for a main effect is going to be “small” then the value of eta.sq
does not need to be included when creating the list for the main effect. There is a default setting of “small” for this value.
# Example of using the default eta.sq setting
main.eff <- list(name = "A", levels = 3)
Interaction Effect Sizes (optional)
As noted in the 2-way ANOVA example, there are two different ways to change the effect sizes for the interactions. For this example, all of the effect sizes for the interaction effects were estimated to be approximately a medium effect. Therefore the most efficient way to change all the effect sizes simultaneously is to use interaction.eta2 = 0.0588
. Alternatively, if only a selection of the interactions were expected to have a moderate effect size, we could change these independently. The following is an example of how this could be achieved.
# Changing the effect sizes of specific interactions
int.eff1 <- list(name = "Age*Conditions", eta.sq = "med")
int.eff2 <- list(name = "Sex*Conditions", eta.sq = "med")
Note: When typing out the name of an interaction it is important to follow the order in which the main effects were defined. For example, name = "Age*Conditions"
is valid whereas name = "Conditions*Age"
would not be.
Running n.multiway
n.multiway(iv1 = main.eff1, iv2 = main.eff2, iv3 = main.eff3, interaction.eta2 = 0.0588)
#>
#> The following sample size recommendations are for each treatment and all possible interactions.
#> Sample sizes are calculated independently using the estimated effect size to achieve
#> the desired power level.
#>
#> Desired power: 0.80
#> Significance level: 0.05
#> Effect size used in calculations: Cohen's f-squared
#> Cutoffs: small = 0.01, med = 0.06, large = 0.14
#>
#> Treatment Effect Size Total n per cell
#> Sex 0.0099 809 34
#> Age 0.0588 179 8
#> Conditions 0.1506 86 4
#> Sex*Age 0.0588 179 8
#> Sex*Conditions 0.0588 199 9
#> Age*Conditions 0.0588 242 11
#> Sex*Age*Conditions 0.0588 242 11
Here is an example of running the function while only changing the effect sizes of the two interactions we defined earlier.
n.multiway(iv1 = main.eff1, iv2 = main.eff2, iv3 = main.eff3, int1 = int.eff1, int2 = int.eff2)
#>
#> The following sample size recommendations are for each treatment and all possible interactions.
#> Sample sizes are calculated independently using the estimated effect size to achieve
#> the desired power level.
#>
#> Desired power: 0.80
#> Significance level: 0.05
#> Effect size used in calculations: Cohen's f-squared
#> Cutoffs: small = 0.01, med = 0.06, large = 0.14
#>
#> Treatment Effect Size Total n per cell
#> Sex 0.0099 809 34
#> Age 0.0588 179 8
#> Conditions 0.1506 86 4
#> Sex*Age small 978 41
#> Sex*Conditions med 195 9
#> Age*Conditions med 237 10
#> Sex*Age*Conditions small 1373 58