modularity | R Documentation |
Computes (signed) modularity statistic given a network and community structure. Allows the resolution parameter to be set
modularity(network, memberships, resolution = 1, signed = FALSE)
network |
Matrix or data frame. A symmetric matrix representing a network |
memberships |
Numeric (length = |
resolution |
Numeric (length = 1).
A parameter that adjusts modularity to
prefer smaller ( |
signed |
Boolean (length = 1).
Whether signed or absolute modularity should be computed.
The most common modularity metric is defined by positive values only.
Gomez et al. (2009) introduced a signed version of modularity that
will discount modularity for edges with negative values. This property
isn't always desired for psychometric networks. If |
Returns the modularity statistic
Alexander P. Christensen <alexpaulchristensen@gmail.com> with assistance from GPT-4
Gomez, S., Jensen, P., & Arenas, A. (2009). Analysis of community structure in networks of correlated data. Physical Review E, 80(1), 016114.
# Load data
wmt <- wmt2[,7:24]
# Estimate EGA
ega.wmt <- EGA(wmt, model = "glasso")
# Compute standard (absolute values) modularity
modularity(
network = ega.wmt$network,
memberships = ega.wmt$wc,
signed = FALSE
)
# 0.1697952
# Compute signed modularity
modularity(
network = ega.wmt$network,
memberships = ega.wmt$wc,
signed = TRUE
)
# 0.1701946
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.