Skip to contents

For tests that may be dependent. Native implementation of the asymptotically exact harmonic mean p-value (Wilson 2019): the statistic \(mean(1/p)\) is referred to its Landau asymptotic distribution. Cross-validated against harmonicmeanp.

Usage

harmonic_mean_p(p_values)

Arguments

p_values

Numeric vector of raw p-values.

Value

A numeric value.

Examples

# Combined p-value robust to dependence between tests.
harmonic_mean_p(c(0.001, 0.05, 0.5))
#> [1] 0.004710834

# Dominated by the smallest p-values (a few strong signals carry it).
harmonic_mean_p(c(0.0001, 0.9, 0.9, 0.9))
#> [1] 0.0005962707

# All-null inputs stay large.
harmonic_mean_p(c(0.4, 0.5, 0.6))
#> [1] 0.7037525

# Unlike Fisher/Stouffer, valid even under arbitrary dependence.
set.seed(1)
harmonic_mean_p(c(runif(5, 0, 0.01), runif(5)))
#> [1] 0.01157731