global_test: Permutation Test for Differences Between Populations of Brain...

View source: R/global_test.R

global_testR Documentation

Permutation Test for Differences Between Populations of Brain Networks

Description

Tests for differences between two or more populations of brain networks, using the L1-distance ANOVA statistic T of Fraiman and Fraiman (2018) and a permutation null distribution. Valid inference requires exchangeable group labels under the null; equal central graphs alone are not enough. This is the global test that identify_critical_links runs before it starts removing edges; here it is available on its own, so that the population-level question can be answered, and reported, before any edge is singled out.

Usage

global_test(
  populations,
  n_permutations = 1000,
  seed = NULL,
  criterion = c("combined", "original"),
  method = "fisher"
)

Arguments

populations

A named list with at least two elements. Each element is itself a list of square, binary, symmetric adjacency matrices (zero diagonal, no self-loops), with at least two graphs per population. All graphs must have at least one node and share the same number of nodes.

n_permutations

Positive integer giving the number of permutation replicates used to approximate the null distribution of T. Default 1000.

seed

Optional integer seed for reproducibility of the permutation replicates. Default NULL.

criterion

"combined" (default) evaluates T together with the local statistic U, the smallest marginal p-value of all edges, in one permutation test; "original" uses T alone. See identify_critical_links.

method

Marginal edge test used for U when criterion = "combined": "fisher" (default), "chi.squared" or "prop", as in compute_edge_pvalues. The "prop" method requires exactly two populations. The method is validated for both criteria, including when the graphs have no edges.

Details

The statistic T contrasts the mean distance of each graph to its own population's central graph with its mean distance to every population's central graph (see compute_test_statistic). The test uses the lower tail of T and does not use a normal approximation. Replicates are generated by permuting the group labels across the pooled sample while preserving the group sizes, T is recomputed for each, and p = (1 + \#\{b : T_b \le T_{obs}\}) / (B + 1), which is never below 1 / (B + 1). Ties are counted by comparing the stored values directly. On sparse networks, floating-point roundoff can separate mathematically equal statistics and produce spuriously small p-values. See identify_critical_links for the combined criterion.

Group labels must be exchangeable under the null: shuffling whole graphs must preserve the joint distribution of the observations. Independent graphs drawn from the same graph distribution satisfy this condition. Matching edge means alone does not, because dependence between edges can differ. Unrestricted permutations do not support paired observations, repeated measures, blocks or adjustment for covariates.

The normalisation constant a of compute_test_statistic is fixed at 1. The p value does not depend on it: a rescales the observed statistic and every replicate by the same positive factor, which leaves their comparison unchanged.

Distances sum all matrix entries. For symmetric graphs with zero diagonal, this counts each undirected edge twice, so reported T is twice the value from an upper-triangle-only distance. This shared positive factor does not change the permutation p-value.

The computation uses the edge-wise decomposition of T described in identify_critical_links: the statistic of every replicate is obtained from permuted edge counts through matrix products, rather than by rebuilding graphs and recomputing distances. That decomposition holds for binary graphs, which is why the input must be binary. Calling global_test() and identify_critical_links with the same populations, n_permutations and seed evaluates the same permutations, so the p value returned here is the one that identify_critical_links() records in its p_value component.

Value

An object of class "global_test": a list with the components

statistic

the observed value of T, computed with normalisation constant a = 1.

p_value

the permutation p value of the chosen criterion, computed among the B + 1 values that include the observed one; NA when the graphs have a single node and hence no edges.

p_value_global, p_value_local

the permutation p values of T and of U on their own (p_value_local is NA with criterion = "original").

local_statistic

the observed value of U, the smallest marginal p-value (NA with criterion = "original").

criterion

the criterion used.

null_distribution

numeric vector of length n_permutations holding the statistic of every replicate.

n_permutations

the number of replicates.

group_sizes

named integer vector with the number of graphs in each population.

n_nodes

the number of nodes.

call

the matched call.

A print method is provided.

References

Fraiman, D. and Fraiman, R. (2018) An ANOVA approach for statistical comparisons of brain networks. Scientific Reports, 8, 4746. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1038/s41598-018-23152-5")}.

Winkler, A. M. et al. (2014) Permutation inference for the general linear model. NeuroImage, 92, 381–397. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1016/j.neuroimage.2014.01.060")}.

See Also

compute_test_statistic for the statistic alone, identify_critical_links for the edges behind a rejection, print.global_test.

Examples

control <- generate_category_graphs(n_graphs = 20, n_nodes = 10,
  n_communities = 2, base_intra_prob = 0.6, base_inter_prob = 0.2, seed = 1)
patient <- generate_category_graphs(n_graphs = 20, n_nodes = 10,
  n_communities = 2, base_intra_prob = 0.6, base_inter_prob = 0.4, seed = 2)
populations <- list(Control = control, Patient = patient)

gt <- global_test(populations, n_permutations = 500, seed = 42)
gt
gt$p_value

# The observed statistic is the one compute_test_statistic() returns
all.equal(gt$statistic, compute_test_statistic(populations, a = 1))

# The null distribution is kept, so it can be inspected
summary(gt$null_distribution)

BrainNetTest documentation built on Dec. 3, 2026, 5:08 p.m.