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

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

