pingouin.power_anova

pingouin.
power_anova
(eta=None, k=None, n=None, power=None, alpha=0.05)[source] Evaluate power, sample size, effect size or significance level of a oneway balanced ANOVA.
 Parameters
 etafloat
ANOVA effect size (etasquare == \(\eta^2\)).
 kint
Number of groups
 nint
Sample size per group. Groups are assumed to be balanced (i.e. same sample size).
 powerfloat
Test power (= 1  type II error).
 alphafloat
Significance level (type I error probability). The default is 0.05.
Notes
Exactly ONE of the parameters
eta
,k
,n
,power
andalpha
must be passed as None, and that parameter is determined from the others.Notice that
alpha
has a default value of 0.05 so None must be explicitly passed if you want to compute it.This function is a mere Python translation of the original pwr.anova.test function implemented in the pwr package. All credit goes to the author, Stephane Champely.
Statistical power is the likelihood that a study will detect an effect when there is an effect there to be detected. A high statistical power means that there is a low probability of concluding that there is no effect when there is one. Statistical power is mainly affected by the effect size and the sample size.
For oneway ANOVA, etasquare is the same as partial etasquare. It can be evaluated from the fvalue and degrees of freedom of the ANOVA using the following formula:
\[\eta^2 = \frac{v_1 F^*}{v_1 F^* + v_2}\]Using \(\eta^2\) and the total sample size \(N\), the noncentrality parameter is defined by:
\[\delta = N * \frac{\eta^2}{1  \eta^2}\]Then the critical value of the noncentral Fdistribution is computed using the percentile point function of the Fdistribution with:
\[q = 1  alpha\]\[v_1 = k  1\]\[v_2 = N  k\]where \(k\) is the number of groups.
Finally, the power of the ANOVA is calculated using the survival function of the noncentral Fdistribution using the previously computed critical value, noncentrality parameter, and degrees of freedom.
scipy.optimize.brenth()
is used to solve power equations for other variables (i.e. sample size, effect size, or significance level). If the solving fails, a nan value is returned.Results have been tested against GPower and the R pwr package.
References
 1
Cohen, J. (1988). Statistical power analysis for the behavioral sciences (2nd ed.). Hillsdale,NJ: Lawrence Erlbaum.
 2
Examples
Compute achieved power
>>> from pingouin import power_anova >>> print('power: %.4f' % power_anova(eta=0.1, k=3, n=20)) power: 0.6082
Compute required number of groups
>>> print('k: %.4f' % power_anova(eta=0.1, n=20, power=0.80)) k: 6.0944
Compute required sample size
>>> print('n: %.4f' % power_anova(eta=0.1, k=3, power=0.80)) n: 29.9255
Compute achieved effect size
>>> print('eta: %.4f' % power_anova(n=20, k=4, power=0.80, alpha=0.05)) eta: 0.1255
Compute achieved alpha (significance)
>>> print('alpha: %.4f' % power_anova(eta=0.1, n=20, k=4, power=0.80, ... alpha=None)) alpha: 0.1085