stats.comparison.holm_adjust

stats.comparison.holm_adjust(p_values)

Adjust p-values for multiple testing with the Holm step-down method.

Sorts the raw p-values ascending (stable sort), multiplies the i-th smallest by m - i remaining hypotheses, enforces monotonicity with a running maximum, and caps at 1.0.

Parameters

Name Type Description Default
p_values pd.Series Raw p-values; the index identifies the hypotheses and is preserved. required

Returns

Name Type Description
pd.Series pd.Series: Adjusted p-values in the original index order.

Raises

Name Type Description
ValueError When p_values is empty or contains NaN.

Examples

import pandas as pd
from spotforecast2_safe.stats.comparison import holm_adjust

raw = pd.Series([0.01, 0.02, 0.03, 0.04], index=list("abcd"))
adjusted = holm_adjust(raw)
print(adjusted.to_string())
assert list(adjusted) == [0.04, 0.06, 0.06, 0.06]
a    0.04
b    0.06
c    0.06
d    0.06