statsmodels.stats.multitest.fdrcorrection#

statsmodels.stats.multitest.fdrcorrection(pvals, alpha=0.05, method='indep', is_sorted=False)[source]#

pvalue correction for false discovery rate

This covers Benjamini/Hochberg for independent or positively correlated and Benjamini/Yekutieli for general or negatively correlated tests.

Parameters:
pvalsarray_like, 1d

Set of p-values of the individual tests.

alphafloat, optional

Family-wise error rate. Defaults to 0.05.

method{‘i’, ‘indep’, ‘p’, ‘poscorr’, ‘n’, ‘negcorr’}, optional

Which method to use for FDR correction. {'i', 'indep', 'p', 'poscorr'} all refer to fdr_bh (Benjamini/Hochberg for independent or positively correlated tests). {'n', 'negcorr'} both refer to fdr_by (Benjamini/Yekutieli for general or negatively correlated tests). Defaults to 'indep'.

is_sortedbool, optional

If False (default), the p_values will be sorted, but the corrected pvalues are in the original order. If True, then it assumed that the pvalues are already sorted in ascending order.

Returns:
rejectedndarray, bool

True if a hypothesis is rejected, False if not

pvals_correctedndarray

pvalues adjusted for multiple hypothesis testing to limit FDR

See also

multipletests

Notes

If there is prior information on the fraction of true hypothesis, then alpha should be set to alpha * m/m_0 where m is the number of tests, given by the p-values, and m_0 is an estimate of the true hypothesis. (see Benjamini, Krieger and Yekutieli)

The two-step method of Benjamini, Krieger and Yekutieli that estimates the number of false hypotheses will be available (soon).

Method names can be abbreviated to first letter, ‘i’ or ‘p’ for fdr_bh and ‘n’ for fdr_by.

Benjamini-Hochberg procedure (see Benjamini and Hochberg, 1995)

Define pvals as:

pvals = pval_1 <= pval_2 <= … <= pval_k … <= pval_(m-1) <= pval_m

Compute raw adjusted p-values as:

raw_adj_pval_k = pval_k * m/k, where

  • raw_adj_pval_k is the adjusted pval_k BEFORE a final correction,

  • pval_k is the p-value under consideration,

  • m is the total number of p-values, and

  • k is the rank of pval_k.

Perform a final correction to make sure that adjusted p-values are monotonic:

The final correction is to make sure that adj_pval_k is less than or equal to adj_pval_(k+1). This procedure starts at the last p-value (raw_adj_pval_m) and proceeds until the first p-value (raw_adj_pval_1).

Both methods exposed via this function (Benjamini/Hochberg, Benjamini/Yekutieli) are also available in the function multipletests, as method="fdr_bh" and method="fdr_by", respectively.