statspai.mht¶
mht ¶
Multiple Hypothesis Testing (MHT) module for StatsPAI.
Provides corrections for simultaneous inference across many outcomes or
subgroups --- the single most common gap when Python users replicate
empirical economics workflows that rely on Stata's rwolf or wyoung.
Estimators and utilities:
- Romano-Wolf stepdown (Romano & Wolf 2005, 2016) --- bootstrap FWER control that exploits dependence across test statistics.
- Westfall-Young maxT (Westfall & Young 1993) --- single-step resampling-based FWER control.
- Bonferroni, Holm (1979), Benjamini-Hochberg (1995) --- classical non-resampling adjustments included for comparison.
adjust_pvalues()--- convenience dispatcher across all methods.
RomanoWolfResult
dataclass
¶
Container for Romano-Wolf multiple hypothesis testing results.
Attributes:
| Name | Type | Description |
|---|---|---|
table |
DataFrame
|
One row per outcome with columns: outcome, coef, se, t, p_value, p_rw, p_bonf, p_holm, p_bh. |
n_outcomes |
int
|
|
n_boot |
int
|
|
n_obs |
int
|
|
adjust_pvalues ¶
Adjust p-values for multiple comparisons.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pvalues
|
array - like
|
Unadjusted p-values. |
required |
method
|
str
|
Adjustment method. One of:
For Romano-Wolf or Westfall-Young adjustments (which require
the original data and bootstrap), use :func: |
``'holm'``
|
Returns:
| Type | Description |
|---|---|
ndarray
|
Adjusted p-values. |
Examples:
bonferroni ¶
Bonferroni correction: p_adj = min(p * S, 1).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pvalues
|
array - like
|
Unadjusted p-values. |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
Bonferroni-adjusted p-values. |
holm ¶
Holm (1979) step-down correction.
Sort p-values ascending; for rank i (1-based):
p_adj(i) = max(p_adj(i-1), min(p(i) * (S - i + 1), 1)).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pvalues
|
array - like
|
Unadjusted p-values. |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
Holm-adjusted p-values (in original order). |
benjamini_hochberg ¶
Benjamini-Hochberg (1995) FDR correction.
Sort p-values ascending; for rank i (1-based):
p_adj(i) = min(p(i) * S / i, 1), with reverse-cumulative-min
to enforce monotonicity.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pvalues
|
array - like
|
Unadjusted p-values. |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
BH-adjusted p-values (in original order). |