These functions offer ways to summarise the heterogeneity of an attribute across a network, within groups of a network, or the distribution of ties across this attribute.

network_richness(object, attribute)

node_richness(object, attribute)

network_diversity(object, attribute, clusters = NULL)

node_diversity(object, attribute)

network_homophily(object, attribute)

node_homophily(object, attribute)

network_assortativity(object)

Arguments

object

An object of a migraph-consistent class:

  • matrix (adjacency or incidence) from {base} R

  • edgelist, a data frame from {base} R or tibble from {tibble}

  • igraph, from the {igraph} package

  • network, from the {network} package

  • tbl_graph, from the {tidygraph} package

attribute

Name of a nodal attribute or membership vector to use as categories for the diversity measure.

clusters

A nodal cluster membership vector or name of a vertex attribute.

Functions

  • network_richness(): Calculates the number of unique categories in a network attribute.

  • node_richness(): Calculates the number of unique categories of an attribute to which each node is connected.

  • network_diversity(): Calculates the heterogeneity of ties across a network or within clusters by node attributes.

  • node_diversity(): Calculates the heterogeneity of each node's local neighbourhood.

  • network_homophily(): Calculates how embedded nodes in the network are within groups of nodes with the same attribute

  • node_homophily(): Calculates each node's embeddedness within groups of nodes with the same attribute

  • network_assortativity(): Calculates the degree assortativity in a graph.

network_diversity

Blau's index (1977) uses a formula known also in other disciplines by other names (Gini-Simpson Index, Gini impurity, Gini's diversity index, Gibbs-Martin index, and probability of interspecific encounter (PIE)): $$1 - \sum\limits_{i = 1}^k {p_i^2 }$$, where \(p_i\) is the proportion of group members in \(i\)th category and \(k\) is the number of categories for an attribute of interest. This index can be interpreted as the probability that two members randomly selected from a group would be from different categories. This index finds its minimum value (0) when there is no variety, i.e. when all individuals are classified in the same category. The maximum value depends on the number of categories and whether nodes can be evenly distributed across categories.

network_homophily

Given a partition of a network into a number of mutually exclusive groups then The E-I index is the number of ties between (or external) nodes grouped in some mutually exclusive categories minus the number of ties within (or internal) these groups divided by the total number of ties. This value can range from 1 to -1, where 1 indicates ties only between categories/groups and -1 ties only within categories/groups.

References

Blau, Peter M. (1977). Inequality and heterogeneity. New York: Free Press.

Krackhardt, David and Robert N. Stern (1988). Informal networks and organizational crises: an experimental simulation. Social Psychology Quarterly 51(2), 123-140.

Examples

marvel_friends <- to_unsigned(ison_marvel_relationships, "positive")
network_diversity(marvel_friends, "Gender")
#> [1] 0.306
network_diversity(marvel_friends, "Attractive")
#> [1] 0.35
network_diversity(marvel_friends, "Gender", "Rich")
#> [1] 0.337 0.165
node_diversity(marvel_friends, "Gender")
#>      V1    V2    V3    V4    V5    V6    V7    V8    V9   V10   V11   V12   V13
#> 1     0  0.48     0 0.363 0.340 0.337     0     0     0 0.332 0.408 0.401 0.355
#> # ... with 40 more from this nodeset in the vector.
node_diversity(marvel_friends, "Attractive")
#>      V1    V2    V3    V4    V5    V6    V7    V8    V9   V10   V11   V12   V13
#> 1     0  0.32     0 0.172 0.159 0.133     0 0.375     0 0.188 0.133 0.105 0.260
#> # ... with 40 more from this nodeset in the vector.
network_homophily(marvel_friends, "Gender")
#> [1] -0.285
network_homophily(marvel_friends, "Attractive")
#> [1] -0.632
node_homophily(marvel_friends, "Gender")
#>      V1    V2    V3     V4     V5    V6    V7    V8    V9    V10    V11    V12
#> 1   NaN 0.429    -1 -0.191 -0.343  -0.2    -1    -1   NaN -0.345 -0.114 -0.113
#> # ... with 41 more from this nodeset in the vector.
node_homophily(marvel_friends, "Attractive")
#>      V1     V2    V3     V4     V5     V6    V7     V8    V9    V10    V11
#> 1   NaN -0.143    -1 -0.649 -0.636 -0.633    -1 -0.333   NaN -0.597 -0.829
#> # ... with 42 more from this nodeset in the vector.
network_assortativity(mpn_elite_mex)
#> [1] -0.176