Skip to content

ENH: binom_test 2-sided is minlike, add centered #2735

Open

Description

@josef-pkt

(I didn't realize this before, but I ran into problems explaining binom_test in a notebook.)

binom_test from scipy.stats is reused in statsmodels but it's not a centered test, it's minlike in Fay's terminology

from exactci documentation:

minlike: sum probabilities of all likelihoods equal or less than observed
central: double minimum one-sided p-value
blaker: combine smaller observed tail probability with opposite tail not greater than observed tail

The following function replicates the results from exactci "central"

def binom_test_centered(count, nobs, prop=0.5):
    """two-sided centered binomial test"""
    prob_low = stats.binom.cdf(count, nobs, p_null)
    prob_upp = stats.binom.sf(count - 1, nobs, p_null)
    return 2 * min(prob_low, prob_upp)

Note "minlike" looks more powerful, scipy binom_test matches R's binom.test (verified)
However we need central for consistency with one-sided tests and equivalence tests.

(Note Fisher's exact test as implemented is also minlike)

follow-up

there is currently a function binom_test_reject_interval which is for central binomial and not for minlike. This matches several functions in R, AFAIR, that also don't take into account that the standard binom_test is minlike. The notebook has plots for the difference in power between the two.
R package MESS looks like it has the correct power for minlike binomial test, power.binom.test.

Activity

  1. josef-pkt commented on Dec 20, 2015

    @josef-pkt
    MemberAuthor

    The example and code to look into this is currently in a notebook in josef-pkt/misc#11

  2. josef-pkt commented on May 30, 2016

    @josef-pkt
    MemberAuthor

    followup to merge of #2935 unit tests and check minlike versus central for the proportion_confint

  3. josef-pkt commented on May 4, 2020

    @josef-pkt
    MemberAuthor

    inheriting the behavior

    exact conditional 2-sample poisson test (#6677 (comment)) and, AFAIR, paired binomial test (McNemar) inherit behavior of binom test.

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