Stats 0.4.0 multiplecomparisons benjaminihochberg - CyrilB1531/lodestar GitHub Wiki

Lodestar.Stats 0.4.0. This page is frozen at that release. Read the current documentation for what main says now. A link to a decision or a migration page follows main, and leaves the archive.

MultipleComparisons.BenjaminiHochberg

The Benjamini-Hochberg step-up procedure.

public static double[] BenjaminiHochberg(ReadOnlySpan<double> pValues)

ParameterspValues is the family, at least one value, each in [0, 1]; the span is read, never modified.

Returnsdouble[]: the adjusted p-values, in the input's own order.

ExceptionsArgumentException when pValues is empty. ArgumentOutOfRangeException when a value is NaN or outside [0, 1].

Example — the same five p-values Bonferroni adjusts.

using Lodestar.Stats;

double[] family = [0.001, 0.008, 0.039, 0.041, 0.042];
double[] adjusted = MultipleComparisons.BenjaminiHochberg(family);

double smallest = adjusted[0];   // => 0.005
double largest = adjusted[4];    // => 0.042

Remarks — this controls the expected proportion of false positives among the results called significant, the false discovery rate, rather than Bonferroni's chance of any false positive at all — a weaker guarantee, and one that costs less: every value here is at most what Bonferroni gives the same family, 0.042 against 0.21 on the largest raw p-value above. The procedure walks the sorted p-values from the largest down, keeping a running minimum, which is what keeps the adjusted values monotone in the original order — without it a smaller raw p-value could end up with a larger adjusted one, an ordering inversion the caller would have no reason to expect.

This assumes the tests are independent or positively dependent. BenjaminiYekutieli drops that assumption, at a cost.

Applies to — net10.0, netstandard2.0.

See alsoMultipleComparisons.Bonferroni, MultipleComparisons.BenjaminiYekutieli, the Python equivalence table.

⚠️ **GitHub.com Fallback** ⚠️