View source: R/assortativity.R
| assortativity_attribute | R Documentation |
Computes assortativity with respect to a node attribute, measuring the tendency of nodes to connect to others with similar attribute values. For categorical attributes, this computes the modularity-based nominal assortativity. For numeric attributes, this computes the Pearson correlation between attribute values at edge endpoints.
assortativity_attribute(x, values, directed = NULL, digits = NULL, ...)
homophily(x, values, directed = NULL, digits = NULL, ...)
x |
Network input: matrix, igraph, network, cograph_network, or tna object. |
values |
Named vector of attribute values whose names cover every node name, or an unnamed vector of length equal to the number of nodes, in node order. A numeric vector is treated as scalar and any other vector as nominal. |
directed |
Logical or NULL. If NULL (default), auto-detect. |
digits |
Integer or NULL. Round the coefficient to this many decimal places. Default NULL (no rounding). |
... |
Not used. Any argument supplied here raises an
|
For categorical (nominal) attributes, the coefficient is:
r = \frac{\text{tr}(\mathbf{e}) - \|\mathbf{e}^2\|}{1 - \|\mathbf{e}^2\|}
where \mathbf{e} is the mixing matrix with e_{ij} = fraction of
edges connecting type i to type j.
For numeric (scalar) attributes, the coefficient is the Pearson correlation
between attribute values at edge endpoints (computed over both orientations
of every edge when the network is undirected). Any non-numeric
values vector (character or factor) is treated as nominal.
The coefficient is NA when the network has no edges, when a nominal
attribute has a single category, or when either value vector has zero
variance.
An object of class "cograph_assortativity" with components:
Numeric scalar: assortativity coefficient.
Character: "nominal" or "scalar".
Logical: whether the network was treated as directed.
Numeric: number of nodes.
Numeric: number of edges.
The attribute values used, named by node and in node order.
The original input network.
Newman, M.E.J. (2003). Mixing patterns in networks. Physical Review E, 67(2), 026126. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1103/PhysRevE.67.026126")}
assortativity, detect_communities
cograph::assortativity_attribute(regulation_net, values = rep(c("self", "social"), each = 5))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.