compute_test_statistic: Compute the Test Statistic T for Brain Network Populations

View source: R/compute_test_statistic.R

compute_test_statisticR Documentation

Compute the Test Statistic T for Brain Network Populations

Description

This function computes the test statistic T to assess whether different populations of brain networks originate from the same distribution.

Usage

compute_test_statistic(populations, a = 1)

Arguments

populations

A named list where each element is a list of adjacency matrices for a population. Example: list(Control = list(G1, G2, ...), PatientA = list(G1, G2, ...), PatientB = list(G1, G2, ...))

a

A normalization constant. Default is 1.

Details

This function returns a statistic, not a normal-score test or a p-value. Distances count both matrix triangles, so T is twice its value under an upper-triangle-only distance convention. For permutation inference and its assumptions, see global_test.

Consider independent binary graphs, q in each of m groups (n = mq in total), where edge e is present with probability p_{ke} in group k. Then

E(T) = -\frac{4n}{n - 1} \, \frac{\sqrt{mq}}{a} \sum_e \sum_{k = 1}^{m} (p_{ke} - \bar{p}_e)^2,

where \bar{p}_e is the average of p_{ke} over the groups. It is zero when all groups share their edge probabilities and negative otherwise, which is why small values are evidence of a difference. Individual graphs need not be closer to their own central graph: in Manhattan distance, graphs whose edge probabilities are below 1/2 are on average closer to any central graph with smaller entries than to their own. With unequal group sizes the expectation can be positive even when the groups differ, so the lower-tail test can miss such differences.

Value

A numeric value representing the test statistic T.

Examples

# Generate synthetic populations data
Control <- list(
  generate_random_graph(n_nodes = 5, edge_prob = 0.1),
  generate_random_graph(n_nodes = 5, edge_prob = 0.1)
)
PatientA <- list(
  generate_random_graph(n_nodes = 5, edge_prob = 0.15),
  generate_random_graph(n_nodes = 5, edge_prob = 0.15)
)
PatientB <- list(
  generate_random_graph(n_nodes = 5, edge_prob = 0.2),
  generate_random_graph(n_nodes = 5, edge_prob = 0.2)
)

populations <- list(Control = Control, PatientA = PatientA, PatientB = PatientB)

# Compute the test statistic T
T_value <- compute_test_statistic(populations, a = 1)
print(T_value)

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