Skip to content

FAQ: multipletests 'bh' benjamini-hochberg correction returns a lot of identical p-values #4408

Open

Description

@PDiracDelta

statsmodels.sandbox.stats.multicomp.multipletests 'bh' benjamini-hochberg correction returns a lot of identical p-values, I think the snippet below is self-explanatory. To my (limited) statistical knowledge, this is not supposed to happen.
EDIT: one gets the same results using the R stats library library(stats); p.adjust(pvalues, method = "BH", n=length(pvalues)) so I suppose this behaviour is correct? I will not delete the post until someone can confirm this. If someone can explain this behaviour, that would also be nice.

import numpy as np
np.random.seed(123)
pvalues = np.random.rand(20)
pvalues

array([ 0.69646919, 0.28613933, 0.22685145, 0.55131477, 0.71946897,
0.42310646, 0.9807642 , 0.68482974, 0.4809319 , 0.39211752,
0.34317802, 0.72904971, 0.43857224, 0.0596779 , 0.39804426,
0.73799541, 0.18249173, 0.17545176, 0.53155137, 0.53182759])

multipletests(pvals=pvalues, alpha=0.05, method='fdr_bh', is_sorted=False, returnsorted=False)

... (irrelevant)
array([ 0.77683727, 0.77683727, 0.77683727, 0.77683727, 0.77683727,
0.77683727, 0.9807642 , 0.77683727, 0.77683727, 0.77683727,
0.77683727, 0.77683727, 0.77683727, 0.77683727, 0.77683727,
0.77683727, 0.77683727, 0.77683727, 0.77683727, 0.77683727]),
0.0025613787765302876,
0.0025)

Activity

  1. PDiracDelta commented on Mar 29, 2018

    @PDiracDelta
    Author

    Updated original post (behaviour might actually be correct and not a bug at all)

  2. josef-pkt commented on Mar 29, 2018

    @josef-pkt
    Member

    I'm pretty sure that this is correct, unit tests are against R stats and/or R package multtest
    (except "The 'fdr_gbs' procedure is not verified against another package" from the docstring.)

    Most of the pvalue correction that are step-up or step-down methods have an adjustment that makes pvalues monotonic, and can cause identical corrected pvalues even if raw pvalues differ, e.g.

    pvals_corrected = np.minimum.accumulate(pvals_corrected_raw[::-1])[::-1]

    (It's a bit more complicated, because there is an initial correction with the Bonferroni or Sidak correction at each stage. In terms of the original values it is more like a condition that the pvalues cross a straight line (ray from zero) only once.
    But I don't remember the details for each type of p-value correction, and given that it doesn't look like a bug, I won't try to remember now.)

    BTW:
    multiple testing functions have been moved out of the sandbox to
    statsmodels\stats\multitest.py

    multiple comparison, tukey_hsd, is still located in the sandbox, but the official access is through
    statsmodels\stats\multicomp.py
    The multicomp code will most likely be moved out of the sandbox in the following statsmodels version, 0.10.

  3. josef-pkt commented on Mar 29, 2018

    @josef-pkt
    Member

    I added the FAQ label so we can keep the issue open.
    The example looks good for illustrating this because so many pvalues are corrected to the same values.

  4. PDiracDelta commented on Mar 29, 2018

    @PDiracDelta
    Author

    Alright, thanks for the quick reply and explanation josef! :)
    (I understand from your comment I should not close the issue, right?)

  5. josef-pkt commented on Mar 29, 2018

    @josef-pkt
    Member

    Right, don't close.
    FAQ issues are often convenient to quickly check some information.
    They can be ignored when we look at the github issues in terms of a bug-tracker.

  6. changed the title [-]statsmodels.sandbox.stats.multicomp.multipletests 'bh' benjamini-hochberg correction returns a lot of identical p-values[/-] [+]FAQ: multipletests 'bh' benjamini-hochberg correction returns a lot of identical p-values[/+] on Aug 28, 2021
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