simpson: Simpson's index and related measures

simpsonR Documentation

Simpson's index and related measures

Description

These measures are based on the sum of squared species proportions. The function dominance() gives this quantity, simpson() gives one minus this quantity, invsimpson() gives the reciprocal of the quantity, and simpson_e gives the reciprocal divided by the number of species.

Usage

simpson(x)

dominance(x)

invsimpson(x)

simpson_e(x)

Arguments

x

A numeric vector of species counts or proportions.

Details

For a vector of species counts x, the dominance index is defined as

D = \sum_i p_i^2,

where p_i is the species proportion, p_i = x_i / N, and N is the total number of counts. This is equal to the probability of selecting two individuals from the same species, with replacement. Relation to other definitions:

  • Equivalent to dominance() in skbio.diversity.alpha.

  • Similar to the simpson calculator in Mothur. They use the unbiased estimate p_i = x_i (x_i - 1) / (N (N -1)).

Simpson's index is defined here as 1 - D, or the probability of selecting two individuals from different species, with replacement. Relation to other definitions:

  • Equivalent to diversity() in vegan with index = "simpson".

  • Equivalent to simpson() in skbio.diversity.alpha.

The inverse Simpson index is 1/D. Relation to other definitions:

  • Equivalent to diversity() in vegan with index = "invsimpson".

  • Equivalent to enspie() in skbio.diversity.alpha.

  • Similar to the invsimpson calculator in Mothur. They use the unbiased estimate p_i = x_i (x_i - 1) / (N (N -1)).

Simpson's evenness index is the inverse Simpson index divided by the number of species observed, 1 / (D S). Relation to other definitions:

  • Equivalent to simpson_e() in skbio.diversity.alpha.

Please be warned that the naming conventions vary between sources. For example Wikipedia calls D the Simpson index and 1 - D the Gini-Simpson index. We have followed the convention from vegan, to avoid confusion within the R ecosystem.

Value

The value of the dominance (0 < D \leq 1), Simpson index, or inverse Simpson index. The dominance is undefined if the vector sums to zero, in which case we return NaN.

Examples

x <- c(15, 6, 4, 0, 3, 0)
dominance(x)

# Simpson is 1 - D
simpson(x)
1 - dominance(x)

# Inverse Simpson is 1/D
invsimpson(x)
1 / dominance(x)

# Simpson's evenness is 1 / (D * S)
simpson_e(x)
1 / (dominance(x) * richness(x))

kylebittinger/abdiv documentation built on Nov. 22, 2023, 8:16 p.m.