View source: R/assortativity.R
| assortativity | R Documentation |
Computes the degree assortativity coefficient, measuring the tendency of nodes to connect to other nodes with similar degree. Positive values indicate assortative mixing (high-degree nodes connect to high-degree nodes), negative values indicate disassortative mixing.
assortativity(x, directed = NULL, type = NULL, digits = NULL, ...)
x |
Network input: matrix, igraph, network, cograph_network, or tna object. |
directed |
Logical or NULL. If NULL (default), auto-detect from matrix symmetry. Set TRUE to force directed, FALSE to force undirected. |
type |
Character string specifying which degree correlation to compute,
or NULL (default) to choose automatically: |
digits |
Integer or NULL. Round result to this many decimal places. Default NULL (no rounding). |
... |
Currently unused; |
The degree assortativity coefficient is defined as the Pearson correlation coefficient between the degrees of nodes at either end of each edge (Newman 2002):
r = \frac{\sum_{jk} jk(e_{jk} - q_j q_k)}{\sigma_q^2}
where e_{jk} is the fraction of edges connecting degree-j to
degree-k vertices, q_k is the excess degree distribution, and
\sigma_q^2 its variance.
Because the Pearson correlation is invariant to subtracting a constant, the implementation computes the correlation of the raw (rather than excess) degrees at the two ends of each edge, counting every undirected edge in both orientations; this is numerically identical to the formula above.
For directed networks, the coefficient is the Pearson correlation between
the source-end and target-end degrees over each edge in its stored
orientation, with the degree mode at each end chosen by type
(Foster et al. 2010).
The coefficient is NA when the network has no edges or when either
degree vector has zero variance.
An object of class "cograph_assortativity" with components:
Numeric scalar: the assortativity coefficient in
[-1, 1].
Character: the degree type used.
Logical: whether the network was treated as directed.
Integer: number of nodes.
Integer: number of edges.
The original input network.
Newman, M.E.J. (2002). Assortative mixing in networks. Physical Review Letters, 89(20), 208701. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1103/PhysRevLett.89.208701")}
Foster, J.G., Foster, D.V., Grassberger, P., & Paczuski, M. (2010). Edge direction and the structure of networks. PNAS, 107(24), 10815-10820. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1073/pnas.0912671107")}
assortativity_attribute, centrality,
network_summary
# Assortative network (high-degree connect to high-degree)
adj <- matrix(c(
0, 1, 1, 1, 0,
1, 0, 1, 1, 0,
1, 1, 0, 0, 1,
1, 1, 0, 0, 1,
0, 0, 1, 1, 0
), 5, 5)
rownames(adj) <- colnames(adj) <- LETTERS[1:5]
cograph::assortativity(adj)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.