Thomas Matthew
Thomas Matthew

Reputation: 2886

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

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?

Upvotes: 0

Views: 5683

Answers (2)

Josef
Josef

Reputation: 22897

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']

Upvotes: 2

MB-F
MB-F

Reputation: 23637

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.

Upvotes: 1

Related Questions