multiplicity

package
v1.0.0-alpha.16 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 17, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package multiplicity is the pure multiple-comparison correction core: it maps one vector of raw p-values to its adjusted twin under a named method (bonferroni, holm, bh, by, none), matching R's stats::p.adjust.

The package is deliberately family-agnostic. It knows nothing about tests, overlays, matrices, rows or columns; a caller assembles one family's p-values into a slice, adjusts it, and maps the result back to its own coordinates.

Contract, shared by every method:

  • the input slice is never mutated; the result is a fresh slice of the same length, position i adjusting input i;
  • NaN inputs are excluded from the family size m and come back as NaN in place (R drops NA from n the same way);
  • results are capped at 1;
  • ties are ordered by original position, and the step-down (holm) and step-up (bh, by) methods enforce monotonicity with a running max / min over the sorted order, so tied inputs adjust equally;
  • with m <= 1 every method returns the input unchanged, as R does.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Adjust

func Adjust(method Method, p []float64) ([]float64, error)

Adjust returns the adjusted p-values of p under method. It errors only on an unknown method; callers validate method names before the fold and surface their own coded error.

func BH

func BH(p []float64) []float64

BH returns the Benjamini-Hochberg step-up adjustment: with the non-NaN p sorted descending, the one of ascending rank i adjusts to min(1, min_{j>=i} (m/j)·p_(j)).

func BY

func BY(p []float64) []float64

BY returns the Benjamini-Yekutieli step-up adjustment: BH scaled by q = sum_{k=1..m} 1/k.

func Bonferroni

func Bonferroni(p []float64) []float64

Bonferroni returns min(1, m·p) for each non-NaN p.

func FamilySize

func FamilySize(p []float64) int

FamilySize returns m, the number of non-NaN p-values in p — the count every method divides or multiplies by.

func Holm

func Holm(p []float64) []float64

Holm returns Holm's step-down adjustment: with the non-NaN p sorted ascending (ties by original position), the k-th (1-based) adjusts to min(1, max_{j<=k} (m-j+1)·p_(j)).

func None

func None(p []float64) []float64

None returns an exact copy of p.

Types

type Method

type Method string

Method names one p-value correction procedure.

const (
	// MethodNone is the identity: the result is an exact copy.
	MethodNone Method = "none"
	// MethodBonferroni multiplies every p by m (family-wise error).
	MethodBonferroni Method = "bonferroni"
	// MethodHolm is Holm's step-down procedure (family-wise error).
	MethodHolm Method = "holm"
	// MethodBH is the Benjamini-Hochberg step-up procedure (false
	// discovery rate under independence or positive dependence).
	MethodBH Method = "bh"
	// MethodBY is the Benjamini-Yekutieli step-up procedure (false
	// discovery rate under arbitrary dependence).
	MethodBY Method = "by"
)

The supported correction methods.

func Methods

func Methods() []Method

Methods returns every supported method, in a stable order.

func (Method) Valid

func (m Method) Valid() bool

Valid reports whether m names a supported method.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL