/
diversity.Rd
83 lines (58 loc) · 4.24 KB
/
diversity.Rd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
% Generated by roxygen2 (4.1.1): do not edit by hand
% Please edit documentation in R/diversity.R
\name{diversity}
\alias{diversity}
\title{Diversity measures}
\usage{
diversity(data, type = "all", method = "euclidean", agg_type = NULL,
q = 0, alpha = 1, beta = 1)
}
\arguments{
\item{data}{A numeric matrix or data frame with objects as rows and categories as columns}
\item{type}{A mnemonic string referencing the diversity measure. List of available measures: "variety", "entropy", "gini", "simpson", "true", "inverse-simpson", "herfindahl–hirschman", "renyi", "evenness", "rao-stirling". A list of short mnemonics for each measure: 'v', 'e', 'g', 's', 't', 'inv', 'hh', 're', ev', and 'rs'. The default for type is "all". More information for each measure in details and examples.}
\item{method}{"rao-stirling" uses a disparity function between objects. List of available disparity methods: "cosine", "jaccard", "euclidean". The default for method is cosine.}
\item{agg_type}{aggregation type for diversity analysis. The analysis is conducted per row but it can also be performed by column setting agg_type = "col". Default is NULL.}
\item{q}{parameter for true diversity index measure. This parameter is also used for the Rényi entropy. Default is 0.}
\item{alpha}{parameter for Rao-Stirling diversity measure. As default we consider alpha=1.}
\item{beta}{parameter for Rao-Stirling diversity measure. As default we consider beta=1.}
}
\value{
A data frame with diversity measures as columns for each object of data
}
\description{
It takes an object x category matrix and calculates a number of diversity measures
}
\details{
Available diversity measures are (written for an object x category matrix):
Variables: N (category count), p_i (proportion of system comprises category i), d_ij (disparity between i and j).
variety: N, category counts per object [MacArthur 1965]
entropy: - sum(p_i log p_i), Shannon entropy per object [Shannon 1948]
gini: 1 - sum(p_i^2), Gini-Simpson index per object [Gini 1912]. It is also known as the Gibbs–Martin index or the Blau index in sociology, psychology and management studies.
simpson: sum(p_i^2), Simpson index per object [Simpson 1949]. This measure is known as the Herfindahl–Hirschman index in economy.
true: (sum(p_i^q))(1-q)^-1, true diversity index per object [Hill 1973]. This measure is q parameterized. Default for q is 0.
berger-parker: it is equals to the maximum p_i value in the dataset, i.e. the proportional abundance of the most abundant type.
inverse-simpson: (sum(p_i^2))^-1, inverse simpson index per object. This measure is the true diversity at q = 2.
renyi: log((sum(p_i^q))(1-q)^-1), Rényi entropy per object. It is a generalization of the Shannon entropy parameterized by q. It corresponds to the logarithm of the true diversity. Default for q is 0.
evenness: (-sum(p_i log p_i))/log N, Shannon evenness per object across categories [Pielou 1969]
rao-stirling: (sum((d_ij)^alpha (p_i p_j)^beta), Rao-Stirling diversity per object across categories [Stirling, 2007]. As default we consider alpha=1 and beta=1.
As pairwise disparities (d_ij) the measure considers Jaccard, Euclidean and Cosine.
}
\examples{
X <- readEdges(path="~/MyDiversity/data/toy.edges", sepr=' ', we=TRUE)
diversity(X, type="gini")
diversity(X, type="rao-stirling", method="cosine")
diversity(X, type="all", method="jaccard")
data <- readCSV(path="~/MyDiversity/data/sitc_cnt_62.csv", sepr=' ', we=TRUE)
diversity(data, type="gini")
diversity(data, type="rao-stirling", method="cosine")
diversity(data, type="all", method="jaccard")
}
\references{
Gini, C. (1912). "Italian: Variabilità e mutabilità" 'Variability and Mutability', Memorie di metodologica statistica.
Hill, M. (1973). "Diversity and evenness: a unifying notation and its consequences". Ecology 54: 427–432.
MacArthur, R. (1965). "Patterns of Species Diversity". Biology Reviews 40: 510-533.
Pielou, E. (1969). "An Introduction to Mathematical Ecology". Wiley.
Shannon, C. (1948). "A Mathematical Theory of Communication". Bell System Technical Journal 27 (3): 379–423.
Simpson, A. (1949). "Measurement of Diversity". Nature 163: 41-48.
Stirling, A. (2007). "A General Framework for Analysing Diversity in Science, Technology and Society". Journal of the Royal Society Interface 4: 707-719.
}