% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/measure_heterogeneity.R
\name{measure_diverse_net}
\alias{measure_diverse_net}
\alias{net_by_richness}
\alias{net_by_diversity}
\title{Measures of network diversity}
\usage{
net_by_richness(.data, attribute)

net_by_diversity(
  .data,
  attribute,
  diversity = c("blau", "teachman", "variation", "gini")
)
}
\arguments{
\item{.data}{A network object of class \code{mnet}, \code{igraph}, \code{tbl_graph}, \code{network}, or similar.
For more information on the standard coercion possible,
see \code{\link[manynet:as_tidygraph]{manynet::as_tidygraph()}}.}

\item{attribute}{Name of a nodal attribute, mark, measure, or membership vector.}

\item{diversity}{Which method to use for \verb{*_diversity()}.
Either "blau" (Blau's index) or "teachman" (Teachman's index) 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.}
}
\value{
A \code{network_measure} numeric score.
}
\description{
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:
\itemize{
\item \code{net_by_richness()} measures the number of unique categories
in a network attribute.
\item \code{net_by_diversity()} measures the heterogeneity of ties across a network.
}
}
\section{Richness}{

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

\section{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)):
\deqn{1 - \sum\limits_{i = 1}^k {p_i^2 }}
where \eqn{p_i} is the proportion of group members in \eqn{i}th category
and \eqn{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.

Teachman's index (1980) is based on information theory
and is calculated as:
\deqn{- \sum\limits_{i = 1}^k {p_i \log(p_i)}}
where \eqn{p_i} is the proportion of group members in \eqn{i}th category
and \eqn{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 \eqn{\sigma}
to the mean \eqn{\mu}:
\deqn{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.
}

\examples{
net_by_richness(ison_networkers)
marvel_friends <- to_unsigned(to_uniplex(fict_marvel, "relationship"), "positive")
net_by_diversity(marvel_friends, "Gender")
net_by_diversity(marvel_friends, "Appearances")
}
\references{
\subsection{On richness}{

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

\subsection{On diversity}{

Blau, Peter M. 1977.
\emph{Inequality and heterogeneity}.
New York: Free Press.

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

Page, Scott E. 2010.
\emph{Diversity and Complexity}.
Princeton: Princeton University Press.
\doi{10.1515/9781400835140}
}
}
\seealso{
Other diversity:
\code{\link{measure_assort_net}},
\code{\link{measure_assort_node}},
\code{\link{measure_diverse_node}}

Other measures:
\code{\link{measure_assort_net}},
\code{\link{measure_assort_node}},
\code{\link{measure_breadth}},
\code{\link{measure_broker_node}},
\code{\link{measure_broker_tie}},
\code{\link{measure_brokerage}},
\code{\link{measure_central_between}},
\code{\link{measure_central_close}},
\code{\link{measure_central_degree}},
\code{\link{measure_central_eigen}},
\code{\link{measure_centralities_between}},
\code{\link{measure_centralities_close}},
\code{\link{measure_centralities_degree}},
\code{\link{measure_centralities_eigen}},
\code{\link{measure_closure}},
\code{\link{measure_closure_node}},
\code{\link{measure_cohesion}},
\code{\link{measure_core}},
\code{\link{measure_diffusion_infection}},
\code{\link{measure_diffusion_net}},
\code{\link{measure_diffusion_node}},
\code{\link{measure_diverse_node}},
\code{\link{measure_features}},
\code{\link{measure_fragmentation}},
\code{\link{measure_hierarchy}},
\code{\link{measure_periods}}
}
\concept{diversity}
\concept{measures}
