Background
I would like to perform a power analysis for the interaction effect in a 2 by 2 within-within ANOVA design. I would like to crosscheck that I am performing this correctly using the pwr::pwr.f2.test()
function in R.
Required inputs
The pwr::pwr.f2.test()
function requires the following parameters:
u
: degrees of freedom for numeratorv
: degrees of freedom for denominatorf2
: the effect size Cohen's $f^2$sig.level
: $\alpha$ levelpower
: the desired power ($1 - \beta$)
We will omit v
so the function will estimate this value.
Inputs for a $2 \times 2$ within-within design
u
The numerator degrees of freedom for an interaction effect in this design is given as:
$$u = A \times B = (a - 1)(b - 1)$$
Where $a$ is the number of levels of Factor $A$, and $b$ is the number of levels of Factor $B$. Therefore, u
is:
$$u = (2-1) \times (2-1) = 1$$
f2
Let's assume I have estimated that the interaction effect should be $\eta^2_p$ = 0.2. I can convert this to $f^2$ using the following formula:
$$f^2 = \frac{\eta^2_p}{1 - \eta^2_p}$$
Therefore, f2
is:
$$f^2 = \frac{0.2}{1-0.2} = 0.25$$
sig.level
I will set $\alpha = .05$
power
I will set $power = 0.80$
Perform the analysis
We use the above inputs in the following power analysis:
pwr::pwr.f2.test(u = 1, f2 = 0.25, sig.level = 0.05, power = 0.8)
Multiple regression power calculation
u = 1
v = 31.42944
f2 = 0.25
sig.level = 0.05
power = 0.8
The required denominator degrees of freedom to detect our effect with 80% power is 31.42. To convert v
to the total $N$ required we will do some simple algebra.
The denominator degrees of freedom for a $2 \times 2$ interaction effect is given as:
$$v = A \times B \times S = (a - 1)(b - 1)(N - 1)$$
Where $N$ is the total sample size. In our study this is:
$$v = (2 - 1)(2 - 1)(N - 1) = N - 1$$
$$N = v + 1$$
This means we simply add 1 to v
to estimate the required sample size, and round up:
ceiling(31.42944 + 1)
[1] 33
The required sample size is therefore $N = 33$.
Question
Have I performed these steps correctly?