Learn R Programming

vegan (version 1.4-2)

diversity: Ecological Diversity Indices and Rarefaction Species Richness

Description

Shannon and Simpson diversity indices and rarefied species richness for community ecologists.

Usage

diversity(x, index = "shannon", MARGIN = 1, base = exp(1))
rarefy(x, sample, MARGIN = 1)

Arguments

x
Community data matrix.
index
Diversity index, one of shannon, simpson or invsimpson.
MARGIN
Margin for which the index is computed.
base
The logarithm base used in shannon.
sample
Subsample size for rarefying community.

Value

  • Vector of diversity indices or rarefied species richness values.

Details

Shannon or Shannon--Weaver (or Shannon--Wiener) index is defined as $H' = -\sum_i p_i \log_{b} p_i$, where $p_i$ is the proportional abundance of species $i$ and $b$ is the base of the logarithm. It is most popular to use natural logarithms, but some argue for base $b = 2$ (which makes sense, but no real difference).

Both variants of Simpson's index are based on $S = \sum p_i^2$. Choice simpson returns $1-S$ and invsimpson returns $1/S$.

Function rarefy gives the expected species richness in random subsamples of size sample from the community. The maximum permissible sample size is $N - \max(n_i)$, where $N$ is the total number of individuals and $n_i$ are the abundances of species on site $i$. Please note that rarefaction can be done only with real counts of individuals: the current function will silently truncate abundances to integers and give wrong results. The function rarefy is based on Hurlbert's (1971) formulation.

Better histories can be told about Simpson's index than about Shannon's index, and still more grandiose stories about rarefaction (Hurlbert 1971). However, these indices are all very closely related, and there is no reason to despise one more than others (but if you are a graduate student, don't drag me in, but obey your Professor's orders).

References

Hurlbert, S.H. (1971). The nonconcept of species diversity: a critique and alternative parameters. Ecological Monographs 54: 187-211.

Examples

Run this code
data(varespec)
H <- diversity(varespec)
## Species richness (S) and Pielou's evenness (J):
S <- apply(varespec>0, 1, sum)
J <- H/log(S)

Run the code above in your browser using DataLab