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

  • net_by_richness() measures the number of unique categories in a network attribute.

  • net_by_diversity() measures the heterogeneity of ties across a network. Where a membership is given, it instead measures the heterogeneity within each group, as the mean over the groups weighted by their size, such as for the groups from node_in_roulette().

net_by_richness(.data, attribute)

net_by_diversity(
  .data,
  attribute,
  diversity = c("blau", "teachman", "variation", "gini", "rao"),
  membership = NULL,
  normalized = TRUE,
  distance = NULL
)

Arguments

.data

A network object of class stocnet, igraph, tbl_graph, network, or similar. Internally any of these will be coerced to an efficient implementation. For more information on possible coercions, see e.g. manynet::as_stocnet().

attribute

Name of a nodal attribute, mark, measure, or membership vector. Where none is named and the network holds only one nodal attribute besides the reserved ones, such as "label" and "mode", that one is used.

diversity

Which method to use for *_diversity(). Either "blau" (Blau's index), "teachman" (Teachman's index), or "rao" (Rao-Stirling diversity) for categorical attributes, or "variation" (coefficient of variation) or "gini" (Gini coefficient) for numeric attributes. Default is "blau". If an incompatible method is chosen for the attribute type, a suitable alternative will be used instead with a message.

membership

A character string naming an existing node attribute in the network, or a categorical vector of the same length as the number of nodes in the network where each element indicates the group membership of the corresponding node. While this may often be a vector created using node_in_*() functions, it can be any character vector that assigns nodes to groups or categories.

normalized

Logical scalar, whether Blau's index is divided by its maximum for the attribute, \(1 - 1/k\), where \(k\) is the number of categories the attribute holds in the network. The index then runs from 0 to 1 whatever the number of categories, as the index of qualitative variation does (Agresti and Agresti 1978). The other indices are left as they are. By default TRUE.

distance

For diversity = "rao", the distances among the categories of the attribute: a matrix whose row and column names are the categories, or a one-mode network of the categories, with values between 0 (the same) and 1 (the most different). By default NULL, so every two categories are 1 apart.

Value

A network_measure numeric score.

The object also carries the measure it computed, the range its values can fall within, and whether and how those values were normalized. These are shown as a one-line header when the object is printed. Where a measure offers a choice between several ways of counting the same thing, it also carries the variant it used. All can be retrieved with attr().

Richness

Richness is a simple count of the number of different categories present for a given attribute.

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: it is \(1 - 1/k\), where the nodes are spread evenly over them, so 0.5 for a binary attribute. With normalized = TRUE, the default, the index is divided by that maximum, so that attributes with different numbers of categories can be compared.

The Herfindahl-Hirschman index (HHI) is the complement of Blau's index, \(\sum\limits_{i = 1}^k {p_i^2}\), and so 1 - net_by_diversity(.data, attribute, normalized = FALSE) returns it. Where shares are stated as percentages rather than proportions, as in the {hhi} package, the index runs from 0 to 10000 and equals (1 - blau) * 10000. Both readings hold for a categorical attribute, where a share is the frequency of a category, which is why neither index is offered for a numeric one.

Teachman's index (1980) is based on information theory and is calculated as: $$- \sum\limits_{i = 1}^k {p_i \log(p_i)}$$ 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 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. It thus shares similar properties to Blau's index, but includes also a notion of richness that tends to give more weight to rare categories and thus tends to highlight imbalances more.

The coefficient of variation (CV) is a standardised measure of dispersion of a probability distribution or frequency distribution. It is defined as the ratio of the standard deviation \(\sigma\) to the mean \(\mu\): $$CV = \frac{\sigma}{\mu}$$ It is often expressed as a percentage. The CV is useful because the standard deviation of data must always be understood in the context of the mean of the data. The CV is particularly useful when comparing the degree of variation from one data series to another, even if the means are drastically different from each other.

The Gini coefficient is a measure of statistical dispersion that is intended to represent the income or wealth distribution of a nation's residents, and is commonly used as a measure of inequality. It is defined as a ratio with values between 0 and 1, where 0 corresponds with perfect equality (everyone has the same income) and 1 corresponds with perfect inequality (one person has all the income, and everyone else has zero income). The Gini coefficient can be calculated from the Lorenz curve, which plots the proportion of the total income of the population that is cumulatively earned by the bottom x% of the population. The Gini coefficient is defined as the area between the line of equality and the Lorenz curve, divided by the total area under the line of equality.

Rao-Stirling diversity (Rao 1982; Stirling 2007) also counts how different the categories are from each other: $$\sum\limits_{i \neq j} d_{ij} p_i p_j$$ where \(d_{ij}\) is the distance between categories \(i\) and \(j\), given as distance. It is the expected distance between the categories of two members selected at random. A group that spans distant categories, such as distant disciplines, is thus more diverse than one that spans close categories, which is why it is used to measure interdisciplinarity (Porter and Rafols 2009). Where every two categories are 1 apart, it is Blau's index. It runs from 0 to 1, and is not normalised: normalized has no effect on it.

References

On richness

Magurran, Anne E. 1988. Ecological Diversity and Its Measurement. Princeton: Princeton University Press. doi:10.1007/978-94-015-7358-0

On diversity

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

Agresti, Alan, and Barbara F. Agresti. 1978. "Statistical analysis of qualitative variation". Sociological Methodology, 9: 204-237.

Teachman, Jay D. 1980. Analysis of population diversity: Measures of qualitative variation. Sociological Methods & Research, 8:341-362. doi:10.1177/004912418000800305

Page, Scott E. 2010. Diversity and Complexity. Princeton: Princeton University Press. doi:10.1515/9781400835140

Hirschman, Albert O. 1964. "The paternity of an index". The American Economic Review, 54(5): 761.

Rao, C. Radhakrishna. 1982. "Diversity and dissimilarity coefficients: A unified approach". Theoretical Population Biology, 21(1): 24-43. doi:10.1016/0040-5809(82)90004-1

Stirling, Andy. 2007. "A general framework for analysing diversity in science, technology and society". Journal of the Royal Society Interface, 4(15): 707-719. doi:10.1098/rsif.2007.0213

Porter, Alan L., and Ismael Rafols. 2009. "Is science becoming more interdisciplinary? Measuring and mapping six research fields over time". Scientometrics, 81(3): 719-745. doi:10.1007/s11192-008-2197-2

Examples

net_by_richness(ison_networkers, "Discipline")
#> # Richness [1, Inf)
#> [1] 4
marvel_friends <- to_unsigned(to_layer(fict_marvel, "relationship"), "positive")
net_by_diversity(marvel_friends, "Gender")
#> # Blau's index, normalized [0, 1]
#> [1] 0.612
net_by_diversity(marvel_friends, "Appearances")
#> # Coefficient of variation (-Inf, Inf)
#> [1] 0.802
net_by_diversity(marvel_friends, "Gender",
  membership = node_in_roulette(marvel_friends, groups = 3, attribute = "Gender"))
#> # Blau's index, normalized [0, 1]
#> [1] 0.61