Skip to content

Sison-Glaz multinomial_proportions_confint fails for small sizes #9587

Closed

Description

@kno10

Describe the bug

statsmodels.stats.proportion.multinomial_proportions_confint fails with method="sison-glaz" for degenerate data. Goodman still gives a result.

https://www.statsmodels.org/dev/generated/statsmodels.stats.proportion.multinomial_proportions_confint.html
says:

When method == 'sison-glaz', if for some reason c cannot be computed; this signals a bug and should be reported.

hence this report

Code Sample, a copy-pastable example if possible

import statsmodels.stats.proportion
statsmodels.stats.proportion.multinomial_proportions_confint(
    [6, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0], method="sison-glaz")

Other arrays that fail:
[4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
[0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0]
[2, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0]

Using version 0.14.4

Expected Output

A result roughly similar to goodman.

Output of import statsmodels.api as sm; sm.show_versions()

Details

INSTALLED VERSIONS

Python: 3.11.13.final.0
OS: Linux 6.1.123+ #1 SMP PREEMPT_DYNAMIC Sun Mar 30 16:01:29 UTC 2025 x86_64
byteorder: little
LC_ALL: en_US.UTF-8
LANG: en_US.UTF-8

statsmodels

Installed: 0.14.4 (/usr/local/lib/python3.11/dist-packages/statsmodels)

Required Dependencies

cython: 3.0.12 (/usr/local/lib/python3.11/dist-packages/Cython)
numpy: 2.0.2 (/usr/local/lib/python3.11/dist-packages/numpy)
scipy: 1.15.3 (/usr/local/lib/python3.11/dist-packages/scipy)
pandas: 2.2.2 (/usr/local/lib/python3.11/dist-packages/pandas)
dateutil: 2.9.0.post0 (/usr/local/lib/python3.11/dist-packages/dateutil)
patsy: 1.0.1 (/usr/local/lib/python3.11/dist-packages/patsy)

Optional Dependencies

matplotlib: 3.10.0 (/usr/local/lib/python3.11/dist-packages/matplotlib)
backend: module://matplotlib_inline.backend_inline
cvxopt: 1.3.2 (/usr/local/lib/python3.11/dist-packages/cvxopt)
joblib: 1.5.1 (/usr/local/lib/python3.11/dist-packages/joblib)

Developer Tools

IPython: 7.34.0 (/usr/local/lib/python3.11/dist-packages/IPython)
jinja2: 3.1.6 (/usr/local/lib/python3.11/dist-packages/jinja2)
sphinx: 8.2.3 (/usr/local/lib/python3.11/dist-packages/sphinx)
pygments: 2.19.2 (/usr/local/lib/python3.11/dist-packages/pygments)
pytest: 8.3.5 (/usr/local/lib/python3.11/dist-packages/pytest)
virtualenv: Not installed

Activity

  1. josef-pkt commented on Jul 16, 2025

    @josef-pkt
    Member

    My guess is that this is a limitation of the method. (Too many zeros.)
    But I need to check this when I have time again. (I'm currently on vacation and travelling.)

  2. josef-pkt commented on Jul 16, 2025

    @josef-pkt
    Member

    Brief look at example and code:

    docstring says
    "In
    their paper, Sison & Glaz demo their method with at least 7 categories, so
    len(counts) >= 7 with all values in counts at or above 5 can be used
    as a rule of thumb for the validity of this method.
    "

    Based on this the Sison-Glaz confidence interval would not be a good approximation to a "true" interval.

    Second, based on my brief look at the method, I don't see what the minimum requirement for the existence of the Sison-Glaz confint is. (It has been a long time since I looked at those details.)

    The following example works
    statsmodels.stats.proportion.multinomial_proportions_confint( [60, 0, 0, 10, 0, 0, 0, 0, 0, 0, 0], method="sison-glaz")

    So, technically the method seems to require a larger number of overall counts and can handle the zeros.
    The results even look reasonable

    statsmodels.stats.proportion.multinomial_proportions_confint(
        [60, 0, 0, 10, 0, 0, 0, 0, 0, 0, 0], method="sison-glaz")
    array([[0.78571429, 0.93504269],
           [0.        , 0.07789983],
           [0.        , 0.07789983],
           [0.07142857, 0.22075697],
           [0.        , 0.07789983],
           [0.        , 0.07789983],
           [0.        , 0.07789983],
           [0.        , 0.07789983],
           [0.        , 0.07789983],
           [0.        , 0.07789983],
           [0.        , 0.07789983]])
    
    x = np.array([60, 0, 0, 10, 0, 0, 0, 0, 0, 0, 0])
    x / x.sum()
    array([0.85714286, 0.        , 0.        , 0.14285714, 0.        ,
           0.        , 0.        , 0.        , 0.        , 0.        ,
           0.        ])
    

    and narrower confint than goodman

    statsmodels.stats.proportion.multinomial_proportions_confint(
        [60, 0, 0, 10, 0, 0, 0, 0, 0, 0, 0], method="goodman")
    array([[0.70202244, 0.93857649],
           [0.        , 0.10316149],
           [0.        , 0.10316149],
           [0.06142351, 0.29797756],
           [0.        , 0.10316149],
           [0.        , 0.10316149],
           [0.        , 0.10316149],
           [0.        , 0.10316149],
           [0.        , 0.10316149],
           [0.        , 0.10316149],
           [0.        , 0.10316149]])
    

    I guess, there will not be a way to get around the non-existence of the Sison-Glaz interval if the counts are too small.
    (Similar to other cases where we need a minimum number of observations or counts for a method to produce numerically valid results.)

  3. shipitdev commented on Jun 10, 2026

    @shipitdev
    Contributor

    Hey @josef-pkt ,
    I dug into the implementation in statsmodels/stats/proportion.py. Since this is an inherent mathematical and sample-size limitation of the Sison-Glaz (as you noted above) raising a generic Exception makes it look like an unexpected bug. I'd love to take this up and refactor it to throw a clean, descriptive ValueError explaining the convergence limitation. If that sounds good i'd love to work on this

  4. added 2 commits that reference this issue on Jul 29, 2026
    79d181a
    2a4c640
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