View source: R/cluster-metrics.R
| cluster_significance | R Documentation |
Compares observed modularity against a null model distribution to assess whether the detected community structure is statistically significant.
cluster_significance(
x,
communities,
n_random = 100,
method = c("configuration", "gnm"),
null = c("detect", "fixed"),
seed = NULL
)
csig(
x,
communities,
n_random = 100,
method = c("configuration", "gnm"),
null = c("detect", "fixed"),
seed = NULL
)
x |
Network input: adjacency matrix, igraph object, or cograph_network. |
communities |
A communities object (from |
n_random |
Number of random networks to generate for the null distribution. Default 100. |
method |
Null model type:
|
null |
Which null question to answer. Default
|
seed |
Random seed for reproducibility. Default NULL. |
Two null models are supported. The default, null = "detect",
generates n_random random networks, runs community detection
(Louvain, with fast-greedy fallback) on each, and records the resulting
modularity. Low p-value means the observed partition beats what
detection would return on similar random graphs. null = "fixed"
instead evaluates the user-supplied membership on each null graph, so
low p-value means the partition itself is stronger than it would be on
similar random graphs — a tighter question that isolates the
partition's quality from any detector's behavior.
A significant result (low p-value) indicates that the community structure is stronger than expected by chance for networks with similar properties.
A cograph_cluster_significance object with:
Modularity of the input communities
Mean modularity of random networks
Standard deviation of null modularity
Standardized score: (observed - null_mean) / null_sd
One-sided p-value (probability of observing equal or higher modularity by chance)
Vector of modularity values from null distribution
Null model method used
Which null question was asked ("detect" or "fixed")
Number of random networks generated
See cluster_significance.
Reichardt, J., & Bornholdt, S. (2006). Statistical mechanics of community detection. Physical Review E, 74, 016110.
communities, cluster_quality
g <- igraph::make_graph("Zachary")
comm <- community_louvain(g)
sig <- cluster_significance(g, comm, n_random = 20, seed = 123)
print(sig)
if (requireNamespace("igraph", quietly = TRUE)) {
g <- igraph::make_graph("Zachary")
comm <- community_louvain(g)
csig(g, comm, n_random = 20, seed = 1)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.