Different results for ANOVA power calculation by R and statsmodels I am studying statistics now so the example is from a textbook.
We have 3 groups with means 11.5, 10.1, 9.1 but want to see what would be the test power for a difference of 1.0. So for this assumed case I took the following means: 11.5, 11.1 and 10.5. Standard deviations are 1.3, 2.1 and 2.4, with 26 subjects in each group.
I tried to find the test power with R (results matching the book) and statsmodels (completely different results). What did I do wrong?
R:
    groupmeans <- c(11.5, 11.1, 10.5)
    stdevs <- c(1.3, 2.1, 2.4)
    ngroups <- length(groupmeans); ngroups
    n=26
    within.var <- sum(stdevs**2)/ngroups; within.var
    between.var = var(groupmeans);between.var
    p <- power.anova.test(groups = length(groupmeans), 
                          between.var = var(groupmeans), 
                          within.var = within.var, 
                          sig.level=0.05,n=n)

I get power = 0.3407726
Statsmodels:
    import statsmodels.api
    import pandas as pd
    from statsmodels.stats.power import FTestAnovaPower
    from statsmodels.stats.oneway import effectsize_oneway
    assumption = pd.DataFrame({'means':[11.5, 11.1, 10.5], 
    'standard_deviations': [1.3, 2.1, 2.4], '
    n': [26, 26, 26]})
    assumption['variances'] = assumption.standard_deviations**2
    effectsize_oneway(means = assumption.means,
                                               vars_ = 
                                          assumption.variances,
                                               nobs = 
                                          assumption.n)
    FTestAnovaPower().power(effect_size = 0.0465, nobs = 26, 
                          alpha=0.05, k_groups=3)

I get effect_size=0.04649098708818496
power = 0.05372905483567891
Same power as in R would require an effect size of 0.3740557562540185
    FTestAnovaPower().solve_power(power = 0.34, nobs=26, 
                   alpha=0.05, k_groups=3)

I also tried to calculate effect size according to the definition given in the description of FTestAnovaPower:  mean divided by the standard deviation
    s = assumption.means.std()
    es = 1.0/s
    es = 1.9867985355975657

FTestAnovaPower().power(effect_size = 1.99, nobs = 26, alpha=0.05, k_groups=3)
power = 0.9999999999992575
 A: The 'effect size' in such a computation depends on $\sum (\mu_i - \mu_\cdot)^2,$ where $\mu_\cdot$ is the average of $\mu_i,$ but some
power and sample size procedures use the size of $|\mu_i-\mu_j|$ you want
to be sure to detect. Also, traditional ANOVAs require $\sigma_i^2$ to be the same. Various software programs for power and sample size make somewhat
different simplifying assumptions, and this accounts for some of the
differences among their results.
R program to compute power of one-factor ANOVA given means, standard deviations, and numbers of replications at each of 3 levels.
I like to do some preliminary (or backup) simulations with specified group means and variances, possibly comparing traditional ANOVA with an implementation of Welch-ANOVA, such as R's oneway.test, which doesn't assume equal variances.
Then I know exactly what the inputs are.
For one choice of parameters similar to the ones you suggest, it seems
that about 70 replications per level are required for power about 80%.
(A run with 26 replications per level gave power about 37%.)
set.seed(2020)
m = 10^5;  pv=numeric(m)
n = 70
for(i in 1:m) {
 x1 = rnorm(n, 10.5, 1.3)
 x2 = rnorm(n, 11, 2)
 x3 = rnorm(n, 11.5, 2.5)
 x = c(x1,x2,x3)
 gp = as.factor(rep(1:3, each=n))
 pv[i] = oneway.test(x~gp)$p.val
 }
mean(pv <= 0.05)
[1] 0.80204      # aprx power

Then when I start to use various 'power and sample size' procedures, I
will have a reality check on the results I get from their various
assumptions and simplifications. (Or from any misunderstanding I may
have how to use them.)
Notes: (1) My program uses the R procedure oneway.test. At each iteration
R does all the formatting for a printed display of results, of which I use only the P-value. An advantage is that I know I'm getting the power directly from oneway.test, not from something I programmed, hoping for equivalence. A disadvantage
is longer running time. (If one is doing rough exploration, it is quicker to use $10^4$ iterations for the simulation.)
(2) I used a for-loop instead of one of several more highly recommended replication structures in R. I find that the for-loop is easier for
people unfamiliar with R to understand.
A: The problems com from how functions are defined.
The implementation of the power functions in statsmodels including FTestAnovaPower initially followed the design of G*Power package and R package pwr.
Effect size for anova is defined as Cohen's f. Also nobs are the total number of observations.
The functions for oneway anova use in general squared Cohen's f effect size.
The default is based on unequal variance assumption as in Welch ANOVA. Alternative variance assumptions are equal variance and an approximation for Browne-Forsythe (1971) mean ANOVA.
Following the examples in https://www.statsmodels.org/dev/generated/statsmodels.stats.oneway.effectsize_oneway.html , we can replicate the R results with 3 changes:

*

*use_var="equal" in effect size computation

*use square root of returned effect size to get f instead of f-squared

*use total nobs in power computation

then
    ese = effectsize_oneway(means = assumption.means,
                            vars_ = assumption.variances,
                            nobs = assumption.n, use_var="equal")
    ese, np.sqrt(ese)
    (0.04272062956717256, 0.20668969390652395)    
    
    FTestAnovaPower().power(effect_size=np.sqrt(ese), nobs=3*26, 
                            alpha=0.05, k_groups=3)
    0.34077463829487

Welch, unequal variance, ANOVA
To illustrate power for Welsh ANOVA that BruceET used in his answer, we can compute power with both variance assumptions. BruceET obtained simulated power of 0.80204.
In the following es is effect size under unequal variance assumptions for Welsh ANOVA. The resulting power for 70 observations per group is 0.799, very close to the simulated power.
The second computation uses effect size ese under equal variance assumption intended for standard equal variance ANOVA. The computed power is lower at 0.76 and underestimates the Welch ANOVA power in this case.
FTestAnovaPower().power(effect_size = np.sqrt(es), nobs = 3*70,
                        alpha=0.05, k_groups=3)
0.7994674969056634

FTestAnovaPower().power(effect_size = np.sqrt(ese), nobs = 3*70, 
                        alpha=0.05, k_groups=3)
0.7628744855163619

