Skip to content

FAQ/SUM: hypothesis tests, power - signatures and conventions #8206

Open

Description

@josef-pkt

we should get a more consistent pattern for the signature of functions, including helper functions
When I write new code I don't always remember the pattern, if there is one, and make inconsistent signatures

TBD

basic convention for 2 indep (at least recently):

sample 1 is treatment, sample 2 is control
H0: s1 - s2 - value = 0 and under the alternative it is unequal !=, smaller <, or larger >

in power sample size computation we search for nobs1, given nobs_ratio
nobs2 = nobs1 * nobs_ratio
(If users want to find nobs_ratio for fixed value of nobs2, then they need to flip indices between sample 1 and 2)

in function that can be either for one-sample or two-sample problems,
nobs in helper function can be either (total) nobs or nobs1

std or var in signature
the recent power functions all have std and and so do generic functions in weightstats, e.g. _zstat_generic2

Activity

  1. josef-pkt commented on Mar 31, 2022

    @josef-pkt
    MemberAuthor

    I'm currently working on power for equivalence tests but it is similar in power for other hypothesis tests

    helper function for tost in stats.proportion

    def _power_ztost(mean_low, var_low, mean_upp, var_upp, mean_alt, var_alt,
                     alpha=0.05, discrete=True, dist='norm', nobs=None,
                     continuity=0, critval_continuity=0)
    

    helper functions in stats.power
    nobs is either one-sample nobs, or nobs1 in usage in calling functions

    normal_power(effect_size, nobs, alpha, alternative='two-sided', sigma=1.):
    
    normal_power_het(diff, nobs, alpha, std_null=1., std_alternative=None,
                     alternative='two-sided'):
    
    def normal_sample_size_one_tail(diff, power, alpha, std_null=1.,
                                     std_alternative=None):
    

    return nobs1

    new power in stats.rates: PR #8166
    I think I use nobs2 instead of nobs1 because I followed the PASS convention (?)
    my initial version use var instead of std in following PASS

    def _power_equivalence_het(es_low, es_upp, nobs2, alpha=0.05,
                               std_null_low=None, std_null_upp=None, std_alternative=None):
    

    The original effect_size based power functions in stats.power did not use var and std.
    The std is assumed to be the same in null and alternative and is incorporated in effect size,

    def normal_power(effect_size, nobs, alpha, alternative='two-sided', sigma=1.):
    
    def ttest_power(effect_size, nobs, alpha, df=None, alternative='two-sided'):
    
  2. josef-pkt commented on Apr 1, 2022

    @josef-pkt
    MemberAuthor

    another naming issue mainly internal and generic, summary statistics helper function
    There is no clear naming convention yet

    • statistic, stat: fully normalized test statistic, i.e. zscored for normal distributed tests
    • effect_size, stat (?) : normalized test statistic without sqrt(nobs) used in power
    • effect, stat (?) like diff or ratio differences
      • with value: for diff eff = p1 - p2 - value or for ratio eff = p1 / p2 - value
      • without value: eff = p1 - p2 or eff = p1 / p2 (no common name used yet, called either diff or ratio
      • effect_size (cohen) : effect / std_population as measure of relative size of effect not directly for power
    • ...

    I'm using stat or statistic to mean different things in different functions in statsmodels.stats
    Also interpretation of effect_size varies by function/purpose/application

    related issue:
    which effect in ContrastResults for t_test with affine null constraint, i.e. value != 0 ? with or without value ?
    #742 (comment)

    effect and net_effect ? eff and neff/effn ?

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