Holm-Bonferroni Reject Decisions for a List of P-Values

Quick Overview

Write a Python function that returns Holm-Bonferroni reject decisions for a list of p-values, in the original input order, using statsmodels. It tests the step-down rule behind family-wise error rate control and the details of calling the library correctly.

Holm-Bonferroni Reject Decisions for a List of P-Values

Role: Data Scientist

Category: Analytics & Experimentation

Difficulty: easy

Interview Round: Other

Implement `def holm_reject(pvals: list[float], alpha: float = 0.05) -> np.ndarray` returning Holm-Bonferroni reject decisions (FWER control at `alpha`). Delegate to `statsmodels.stats.multitest.multipletests(pvals, alpha=alpha, method='holm')` and return only its first element (`reject`, index `0`). Requirements: - Return a 1-D NumPy array of dtype `bool` with length `m`. - Preserve the original input order of `pvals`. - Return the `reject` array only, not the corrected p-values. `statsmodels` and `numpy` are available. For example: ```python holm_reject([0.001, 0.008, 0.039, 0.041, 0.042, 0.06, 0.074, 0.205, 0.212, 0.216], 0.05) # -> array([ True, False, False, False, False, False, False, False, False, False]) ``` ```hint Defaults and order Check which correction `multipletests` applies when `method` is left out, and in what order it hands the decisions back. ``` ### What a Strong Answer Covers - Calls `multipletests` with the Holm method and returns only the reject array as a 1-D `bool` array of length `m`. - Shows that the decisions come back in input order, using an unsorted input as a check. - Explains the step-down rule: the threshold at each rank and when the procedure stops. - Traces the example to show why only the first hypothesis is rejected. - Handles edge cases such as an empty list, a single p-value and tied p-values. ### Follow-up Questions - How does the step-down Holm procedure decide rejections? Implement it without `statsmodels`. - When would you prefer Benjamini-Hochberg (`method='fdr_bh'`) over Holm? - How would you report Holm-adjusted p-values, and how do they relate to the reject decisions?

Overview: Write a Python function that returns Holm-Bonferroni reject decisions for a list of p-values, in the original input order, using statsmodels. It tests the step-down rule behind family-wise error rate control and the details of calling the library correctly.

Nov 24, 2026
easyData ScientistOtherAnalytics & Experimentation
0
0

Implement def holm_reject(pvals: list[float], alpha: float = 0.05) -> np.ndarray returning Holm-Bonferroni reject decisions (FWER control at alpha). Delegate to statsmodels.stats.multitest.multipletests(pvals, alpha=alpha, method='holm') and return only its first element (reject, index 0).

Requirements:

  • Return a 1-D NumPy array of dtype bool with length m .
  • Preserve the original input order of pvals .
  • Return the reject array only, not the corrected p-values.

statsmodels and numpy are available.

For example:

holm_reject([0.001, 0.008, 0.039, 0.041, 0.042, 0.06, 0.074, 0.205, 0.212, 0.216], 0.05)
# -> array([ True, False, False, False, False, False, False, False, False, False])

What a Strong Answer Covers Guidance

  • Calls multipletests with the Holm method and returns only the reject array as a 1-D bool array of length m .
  • Shows that the decisions come back in input order, using an unsorted input as a check.
  • Explains the step-down rule: the threshold at each rank and when the procedure stops.
  • Traces the example to show why only the first hypothesis is rejected.
  • Handles edge cases such as an empty list, a single p-value and tied p-values.

Follow-up Questions Guidance

  • How does the step-down Holm procedure decide rejections? Implement it without statsmodels .
  • When would you prefer Benjamini-Hochberg ( method='fdr_bh' ) over Holm?
  • How would you report Holm-adjusted p-values, and how do they relate to the reject decisions?