statsmodels.stats.power.FTestPower

class statsmodels.stats.power.FTestPower(**kwds)[source]

Statistical Power calculations for generic F-test of a constraint

This class is not recommended, use FTestPowerF2 with corrected interface.

This is based on Cohen’s f as effect size measure.

Warning: Methods in this class have the names df_num and df_denom reversed.

See also

FTestPowerF2

Class with Cohen’s f-squared as effect size, corrected keyword names.

Examples

Sample size and power for multiple regression base on R-squared

Compute effect size from R-squared

>>> r2 = 0.1
>>> f2 = r2 / (1 - r2)
>>> f = np.sqrt(f2)
>>> r2, f2, f
(0.1, 0.11111111111111112, 0.33333333333333337)

Find sample size by solving for denominator df, wrongly named df_num

>>> df1 = 1  # number of constraints in hypothesis test
>>> df2 = FTestPower().solve_power(effect_size=f, alpha=0.1, power=0.9,
                                   df_denom=df1)
>>> ncc = 1  # default
>>> nobs = df2 + df1 + ncc
>>> df2, nobs
(76.46459758305376, 78.46459758305376)

verify power at df2

>>> FTestPower().power(effect_size=f, alpha=0.1, df_denom=df1, df_num=df2)
0.8999999972109698

Methods

plot_power([dep_var, nobs, effect_size, ...])

Plot power with number of observations or effect size on x-axis

power(effect_size, df_num, df_denom, alpha)

Calculate the power of a F-test.

solve_power([effect_size, df_num, df_denom, ...])

solve for any one parameter of the power of a F-test


Last update: Oct 03, 2024