Computes an empirical p-value by comparing an observed test statistic against a null distribution. This is the standard approach in MOSAIC for calibrating differential connectivity significance: run the DC pipeline on real labels and on shuffled labels, then compare F-statistics.
Arguments
- test_value
Numeric scalar. The observed test statistic (e.g. a PERMANOVA F-statistic from
run_DC_test).- data_list
Numeric vector of null distribution values (e.g. all F-statistics from a label-shuffled run).
- alternative
Character string specifying the alternative hypothesis:
"greater"(Default) Tests whether
test_valueis unusually large. P-value = proportion of null values >= test_value."less"Tests whether
test_valueis unusually small. P-value = proportion of null values <= test_value."two.sided"Tests whether
test_valueis extreme in either direction. P-value = 2 * one-sided p-value, capped at 1.
See also
run_DC_test which
produces the F-statistics to be tested.
Examples
# Simulate a null distribution and test an observed value
set.seed(42)
null_distribution <- rnorm(10000, mean = 0, sd = 1)
observed <- 2.5
# One-sided test (is the observed value unusually large?)
calculate_empirical_pvalue(observed, null_distribution, alternative = "greater")
#> [1] 0.0058
# Two-sided test
calculate_empirical_pvalue(observed, null_distribution, alternative = "two.sided")
#> [1] 0.0116
# Typical MOSAIC usage:
# pval <- calculate_empirical_pvalue(F_observed, F_null_vector)