Skip to content

BUG/REF/SUMM: problem I mix up df_num and df_denom very often #8651

Closed

Description

@josef-pkt

AFAICS, FTestPower has df_num and df_denom reversed

Note:
ratio = numerator / denominator

scipy F distribution has dfn and dfd as shape parameters

in testing constraints
df_num = df_constraints = number of constraints
df_denom = df_resid of full model, nobs - k

TBC

Activity

  1. josef-pkt commented on Feb 4, 2023

    @josef-pkt
    MemberAuthor

    so far it looks like in statsmodels.stats it's only the F power functions that have it reversed

    in oneway:
    anova_oneway has it reversed in the docstring returns, but not in the code df = (df_denom, df_num) : tuple of floatsanova_generic returns HolderTuple with attributedf=(df_num, df_denom)`

    in power:
    helper function ftest_anova_power uses reversed arg sequence

        crit = stats.f.isf(alpha, df_denom, df_num)
        pow_ = stats.ncf.sf(crit, df_denom, df_num, effect_size**2 * nobs)
    

    and same in ftest_power function

        crit = stats.f.isf(alpha, df_denom, df_num)
        pow_ = stats.ncf.sf(crit, df_denom, df_num, nc)
    

    ftest_anova_power has no bug, incorrect naming is only inside function, args are in terms of nobs and k_groups

    however ftest_power and the corresponding FTestPower methods have the "naming bug" with df_num, df_denom as keywords in signature

    The ftest_power function uses only positional args, so we can change it without backwards compat problems. Except for users that use keywords for positional. I switch to using df1, df2, so using df_num or df_denom as keyword will raise an exception.
    Not really, problem is that the backwards compatible arg sequence would be df2, df1.

  2. bashtage commented on Jul 30, 2026

    @bashtage
    Member

    Fixed by PR #8648, which renamed the internal args (df2, df1) and added a corrected FTestPowerF2 class. The legacy FTestPower intentionally retains the reversed df_num/df_denom naming for backward compatibility, now clearly documented as such. Closing as fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions