0

Statsmodels seems to be the only library for python (besides rpy2) that provides an FDR-based BH adjustment for p-values, but it appears to not be included anymore:

statsmodels.sandbox.stats.multicomp.fdrcorrection0()

AttributeError: module 'statsmodels.sandbox' has no attribute 'stats'

Was this module removed from 0.6.1? Besides using rpy2, is there any other widely used implementation of FDR p-value adjustment?

Thomas Matthew
  • 2,826
  • 4
  • 34
  • 58
  • I don't think the whole `stats` module has been removed. You probably need to import it explicitly. (Besides, `fdrcorrection0` is still in the [master branch](https://github.com/statsmodels/statsmodels/blob/master/statsmodels/sandbox/stats/multicomp.py#L94)) – MB-F Nov 10 '17 at 07:18

2 Answers2

2

The relevant code has been moved out of the sandbox and is now at statsmodels.stats.multitest The sandbox function are just alias for the non-sandbox functions. The online documentation is currently a bit outdated.

The direct import

>>> from statsmodels.stats.multitest import fdrcorrection
>>> fdrcorrection
<function fdrcorrection at 0x0000000008554B70>

using it through the api

>>> import statsmodels.api as sm
>>> sm.stats.fdrcorrection
<function fdrcorrection at 0x0000000008554B70>

this is the old location which currently still contains an alias

>>> from statsmodels.sandbox.stats.multicomp import fdrcorrection0
>>> fdrcorrection0
<function fdrcorrection at 0x0000000008554B70>

edited list of functions in statsmodels.stats.multitest:

>>> import statsmodels.stats.multitest as multi
>>> dir(multi) # output edited
['NullDistribution', 'fdrcorrection', 'fdrcorrection_twostage', 'local_fdr', 'multipletests']
Josef
  • 21,998
  • 3
  • 54
  • 67
1

It's still there in version 0.8.0:

import statsmodels
print(statsmodels.__version__)  
# 0.8.0rc1

from statsmodels.sandbox.stats.multicomp import fdrcorrection0
print(fdrcorrection0)
# <function fdrcorrection at 0x0E5A3E88>

You probably did not import the submodules stats and multipcomp.

MB-F
  • 22,770
  • 4
  • 61
  • 116
  • importing it directly worked. Why is it when I tab-completed `statsmodels.sandbox.` I didn't see it in the list of suggested subpackages? – Thomas Matthew Nov 10 '17 at 07:24
  • Yep. The module needs to be imported so introspection can see its content. – MB-F Nov 10 '17 at 07:48