Skip to content

Bug: multipletests raises exception with empty array #763

Closed

Description

@josef-pkt

From mailing list

I'm trying to use multipletests to correct for multiple comparisons after doing some nonparametric testing (Mann Whitney, Kologorov-Smirnov); it seems to work perfectly except in the case when all the corrected pvalues are still less than alpha (in this case, 0.05). Here's an example from one of my analyses:

In [10]: d=array([2.6055703594036331e-165, 0.011245207233783866, 9.00998740598526e-109, 1.1247302716811245e-07, 3.5737087013141192e-70, 2.6211382176455862e-14, 6.0796933628422312e-130])

In [11]: from statsmodels.sandbox.stats.multicomp import multipletests

In [12]: multipletests(d,method='h')
------------------------------------------------------------
Traceback (most recent call last):
  File "<ipython console>", line 1, in <module>
  File "C:\Python26\lib\site-packages\statsmodels\stats\multitest.py", line 113, in multipletests
    notrejectmin = np.min(np.nonzero(notreject))
  File "C:\Python26\lib\site-packages\numpy\core\fromnumeric.py", line 1861, in amin
    return _wrapit(a, 'min', axis, out)
  File "C:\Python26\lib\site-packages\numpy\core\fromnumeric.py", line 37, in _wrapit
    result = getattr(asarray(obj),method)(*args, **kwds)
ValueError: zero-size array to ufunc.reduce without identity

Is this a known bug and/or is there a way around it? For the moment I'm just trying to get at the booleans so I'm just putting the call inside a 'try' loop and catching the error by returning an array of the same size with all 'True's, but that feels sloppy and I may want the actual corrected p values in the future. I'm running statsmodels 0.4.3 in Python 2.6.5 in Windows. Thanks!

Activity

  1. josef-pkt commented on Apr 10, 2013

    @josef-pkt
    MemberAuthor

    simple case

    sms.multipletests(np.arange(5)/500., method = 'h')
    

    it looks like for 'h' and 'hs', we just need to set notrejectmin index to 0 if not np.any(notreject) ?

    notrejectmin = np.min(np.nonzero(notreject))

  2. added a commit that references this issue on Apr 10, 2013
    5e561e1
  3. josef-pkt commented on Apr 10, 2013

    @josef-pkt
    MemberAuthor

    fix is in a branch josef-pkt@5e561e1
    pvalues were not affected, an example with all rejects produces same p-value correction as R package multtest::mt.rawp2adjp and stats::p.adjust. stats:p.adjust doesn't have Holm-Sidak

  4. josef-pkt commented on Apr 10, 2013

    @josef-pkt
    MemberAuthor

    There is something wrong with that fix.

  5. added a commit that references this issue on May 24, 2013
    01a3a95
  6. added a commit that references this issue on Sep 2, 2014
    587ac35
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

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions