Skip to contents

Richness counted from raw data rises with sampling effort. A site with 500 recorded individuals will, on average, show more species than a neighbour with 50, because more individuals expose more of the rare tail of the community. This article rarefies richness to a common sample size, either a number of individuals (Hurlbert 1971) or a number of sites (Coleman et al. 1982; Colwell et al. 2004), and thins sites that sit so close together that they add little new information. It ends on two sampling tiers compared at matched effort. Installation is covered in Get started; the figures need ggplot2.

Richness rises steeply with the first few dozen individuals and flattens only once the common species are saturated and new records start repeating species already seen. Two sites at different points on that rising curve are not comparable: that site A has 18 species and site B has 11 says little until both numbers refer to the same amount of sampling. Rarefaction answers how many species each site would show at a shared sample size. Standardising by sample coverage fixes a shared completeness instead, which needs abundance counts; when the data are presence/absence, or effort varies through the number of plots, the sample-based curves below are the tool.

  1. Rarefy individuals with rarefy(), for richness and Hill numbers.

  2. Rarefy sites analytically with mao_tau() and coleman(), and trace the survey order with collector().

  3. Thin spatially redundant sites with subsample() or spatialRarefaction().

  4. Compare sites at equal effort with rarefy(n_individuals = ).

Example

Simulating uneven effort

The example data are 60 sites on the unit square, each with Poisson abundances of the same 20 species. The relative abundances rel decline geometrically, each species 0.7 times as abundant as the one before, so a few species are common and the rest form a rare tail. The species pool is fixed, so every site has the same richness ceiling of 20. What differs is the effort lambdas, which scales the expected number of individuals of a site to 20, 60 or 100, for 20 sites each. Any difference in observed richness between these three tiers comes from effort alone, so a standardisation that works should bring the tiers together and one that fails leaves the effort gradient in place. Field surveys never come with this guarantee, which is why a simulation with known truth is used here.

set.seed(42)
n_sites <- 60
coords <- data.frame(x = runif(n_sites), y = runif(n_sites))

rel <- 0.7^(0:19) / sum(0.7^(0:19))
lambdas <- rep(c(1, 3, 5), each = 20)
species <- matrix(0, nrow = n_sites, ncol = 20)
for (i in seq_len(n_sites)) {
  species[i, ] <- rpois(20, lambda = 20 * lambdas[i] * rel)
}
colnames(species) <- paste0("sp", 1:20)

The mean counts per tier show the bias directly.

tier <- factor(lambdas)
indiv <- rowSums(species)
rich <- rowSums(species > 0)
aggregate(cbind(individuals = indiv, richness = rich),
          list(tier = tier), mean)
#>   tier individuals richness
#> 1    1       19.10     7.05
#> 2    3       59.05    10.50
#> 3    5      101.20    11.40

Mean individuals per site track the effort, about 20, 60 and 100. Mean richness rises with them but more slowly, because each added individual is increasingly likely to belong to a common species already recorded, and no tier comes near the ceiling of 20 at a single site. A ranking of these sites by raw richness would recover the effort gradient and nothing else.

Rarefying individuals

rarefy() pools the abundance matrix across sites and returns the expected richness \(E[S_n]\) in a random subsample of \(n\) individuals, over a grid of sample sizes. The expectation is exact (Hurlbert 1971; formula in Rarefaction formulas). The returned spacc_rare object also carries a bootstrap standard error and 95% bounds, the expectation plus or minus 1.96 standard errors.

rare <- rarefy(species)
rare
#> Individual-based rarefaction
#> ---------------------------- 
#> Total individuals: 3587
#> Observed species: 20
#> Bootstrap replicates: 100

as.data.frame() returns the sample sizes, the expected diversity and the bootstrap interval.

rare_df <- as.data.frame(rare)
head(rare_df, 4)
#>     n  expected           sd     lower     upper
#> 1   1  1.000000 1.625488e-11  1.000000  1.000000
#> 2  37  8.793568 1.088367e-01  8.580249  9.006888
#> 3  73 10.608084 1.537504e-01 10.306734 10.909435
#> 4 110 11.710485 1.861883e-01 11.345556 12.075414
tail(rare_df, 2)
#>        n expected        sd    lower    upper
#> 99  3551 19.98977 0.9034842 18.21894 21.76059
#> 100 3587 20.00000 0.9089343 18.21849 21.78151
plot(rare)

Rarefaction curve of expected species richness against number of individuals, rising steeply over the first few hundred individuals and then slowly towards 20 species, with a bootstrap band. 0 5 10 15 20 0 1000 2000 3000 Number of individuals Expected species richness 3587 individuals, 20 species Individual-Based Rarefaction Curve

The expectation rises steeply over the first few hundred individuals, while the common species are found, and then approaches 20 slowly as the rare species are added one by one. A curve that has flattened well before the full sample size marks a community whose common species are saturated; a curve still rising steeply at the full sample size marks an undersampled community whose species total is an underestimate.

Higher orders \(q\) of the Hill numbers weight species by abundance and so down-weight the rare tail. q = 1 and q = 2 return the Shannon and inverse Simpson effective numbers of species, which in this uneven community stay far below the 20 species because they are governed by the few common ones.

rare_q1 <- rarefy(species, q = 1)
rare_q2 <- rarefy(species, q = 2)
c(q0 = max(rare$expected), q1 = max(rare_q1$expected),
  q2 = max(rare_q2$expected))
#>        q0        q1        q2 
#> 20.000000  7.559289  5.681866

rarefy() accepts any non-negative order. Orders 0, 1 and 2 use exact estimators; other orders report the Hill number of order q of the sampled composition.

rare_half <- rarefy(species, q = 0.5)
rare_q3 <- rarefy(species, q = 3)
c(q0.5 = max(rare_half$expected), q3 = max(rare_q3$expected))
#>      q0.5        q3 
#> 10.499660  4.979581

Rarefying sites

Sample-based rarefaction subsamples sites instead of individuals. Three analytical curves need no simulation, and all three binarise the matrix first:

  • mao_tau() is the exact expected sample-based rarefaction of Colwell et al. (2004), with columns sites, expected, sd and analytical 95% bounds lower and upper. The standard deviation is their unconditional one (Eq. 6), which treats the sites as a sample of a larger assemblage whose richness is estimated with Chao2, so it stays above 0 at the full number of sites.

  • coleman() is the expectation of Coleman et al. (1982), with columns sites, expected and sd.

  • collector() counts species in the order of the rows, with columns sites and species, so it traces how the survey actually accumulated species.

mt <- mao_tau(species)
cm <- coleman(species)
cl <- collector(species)
head(mt, 3)
#>   sites expected       sd    lower    upper
#> 1     1  9.65000 1.723569 6.271805 13.02819
#> 2     2 11.76497 1.726477 8.381078 15.14887
#> 3     3 12.95099 1.679002 9.660149 16.24184
curves <- rbind(
  data.frame(sites = mt$sites, S = mt$expected, kind = "Mao Tau"),
  data.frame(sites = cm$sites, S = cm$expected, kind = "Coleman"),
  data.frame(sites = cl$sites, S = cl$species, kind = "Collector")
)
ggplot2::ggplot(curves, ggplot2::aes(sites, S, colour = kind,
                                     linetype = kind)) +
  ggplot2::geom_line(linewidth = 0.9) +
  ggplot2::labs(x = "Sites", y = "Species", colour = NULL,
                linetype = NULL) +
  ggplot2::theme_minimal(base_size = 17)

Species against number of sites for the Mao Tau, Coleman and collector's curves; Mao Tau and Coleman nearly coincide, the collector's curve rises in steps around them. 9 12 15 18 0 20 40 60 Sites Species Coleman Collector Mao Tau

The Mao Tau and Coleman expectations coincide on these data. The collector’s curve departs from them because it follows the arbitrary order of the rows, and the Mao Tau bounds give the analytical uncertainty without a bootstrap. These two expectations are the sample-based analogue of the individual-based curve: they standardise on the number of sites, while rarefy() standardises on the number of individuals. Which axis matters depends on whether effort varies through the number of plots or through the depth of sampling within plots.

Thinning spatially redundant sites

Nearby sites often hold similar species, which inflates the apparent accumulation rate and biases fits such as species-area exponents. subsample() returns the row indices of the sites to keep, so the same indices subset the species matrix and the coordinates and keep them aligned. It has three rules:

  • method = "grid" overlays cells of size cell_size and keeps one random site per occupied cell. Given n instead, it chooses the cell size from the extent of the sites.

  • method = "random" keeps a simple random sample of n sites and ignores geography, which is useful only for matching sample sizes across datasets.

  • method = "thinning" repeatedly takes the closest pair of sites and drops the one with more neighbours closer than min_dist, until no two retained sites are closer than min_dist (Aiello-Lammens et al. 2015).

The grid rule is the fastest and most predictable, and it spreads the retained sites out.

keep <- subsample(coords, method = "grid", cell_size = 0.2, seed = 7)
length(keep)
#> [1] 23

A grid of cell size 0.2 over the unit square has 25 cells, so the 60 sites thin to at most the number of occupied cells. Comparing the accumulation curve on the thinned set with the full set shows how much of the original rise came from neighbouring sites.

set.seed(7)
full <- spacc(species, coords, n_seeds = 30, progress = FALSE)
thin <- spacc(species[keep, ], coords[keep, ], n_seeds = 30,
              progress = FALSE)
thinned <- rbind(transform(as.data.frame(full), set = "Full"),
                 transform(as.data.frame(thin), set = "Thinned (grid)"))
ggplot2::ggplot(thinned, ggplot2::aes(sites, mean, colour = set,
                                      linetype = set)) +
  ggplot2::geom_line(linewidth = 1) +
  ggplot2::labs(x = "Sites", y = "Species", colour = NULL,
                linetype = NULL) +
  ggplot2::theme_minimal(base_size = 17)

Mean species against sites accumulated for the full set of 60 sites and the grid-thinned set of 23 sites; the curves nearly coincide over the first 15 sites and the thinned curve ends at 19 species. 12 15 18 0 20 40 60 Sites Species Full Thinned (grid)

The two curves nearly coincide over the first 15 sites. The thinned set then reaches 19 species with its 23 sites, a count the full set reaches only after about 40, so the spread-out sites add species faster per site than compact groups of neighbours. One rare species was lost with the discarded sites. spatialRarefaction() corrects for the same redundancy without discarding sites: it runs distance-weighted permutations and returns sites, mean, sd and quantile bounds.

set.seed(7)
sr <- spatialRarefaction(species, coords, n_perm = 50)
tail(sr[, c("sites", "mean", "lower", "upper")], 2)
#>    sites mean lower upper
#> 59    59   20    20    20
#> 60    60   20    20    20

Comparing two tiers at equal effort

The lowest and highest tiers share the same 20-species community but differ fivefold in individuals per site. Their raw pooled richness is the starting point: the high tier has recorded every species, the low tier has missed the rarest ones.

lo <- species[lambdas == 1, ]
hi <- species[lambdas == 5, ]
c(low = sum(colSums(lo) > 0), high = sum(colSums(hi) > 0))
#>  low high 
#>   14   20

n_individuals rarefies each tier to one sample size. The size is set by the smaller pool, since a comparison rarefies down to the smallest sample, never up.

n_match <- min(sum(lo), sum(hi))
S_lo <- rarefy(lo, n_individuals = n_match)$expected
S_hi <- rarefy(hi, n_individuals = n_match)$expected
c(low = round(S_lo, 1), high = round(S_hi, 1), n = n_match)
#>   low  high     n 
#>  14.0  15.2 382.0

At the same number of individuals the gap of six species between the tiers shrinks to about one, so the comparison no longer rewards the more deeply sampled tier. Standardising by sample coverage adds the comparison at matched coverage for the same two tiers and a table of when to choose which.

Rarefaction formulas

Individual-based rarefaction

Given a pooled sample of \(N\) individuals containing \(S_{obs}\) species, individual-based rarefaction asks how many species a random subsample of \(n \le N\) individuals, drawn without replacement, would contain. Let \(N_i\) be the total abundance of species \(i\), so that \(N = \sum_i N_i\). Species \(i\) appears in the subsample unless all \(n\) draws avoid it:

\[ P(\text{species } i \in \text{subsample}) = 1 - \frac{\binom{N - N_i}{n}}{\binom{N}{n}}. \]

The expectation of a sum of indicators is the sum of their probabilities, so the expected rarefied richness is (Hurlbert 1971)

\[ E[S_n] = \sum_{i=1}^{S_{obs}} \left[ 1 - \frac{\binom{N - N_i}{n}}{\binom{N}{n}} \right]. \]

Here \(E[S_n]\) is the expected richness at subsample size \(n\), \(N\) the total number of individuals pooled across the sites being compared, \(N_i\) the abundance of species \(i\), and \(S_{obs}\) the number of species in the full pooled sample. The curve starts at 1 when \(n = 1\), rises monotonically and reaches \(S_{obs}\) exactly at \(n = N\). spacc computes it on a log scale to avoid overflow in the binomial coefficients.

Averaging the richness of many random subsamples of size \(n\) would converge to \(E[S_n]\); the formula gives that limit in closed form, faster and without Monte Carlo noise. A curve that has flattened by \(n = N/2\) indicates a community whose common species are saturated, so doubling the remaining effort would add few species. The standard error comes from the bootstrap of Chao et al. (2014), the one iNEXT uses. Resampling the \(N\) observed individuals can only lose species, so near \(n = N\) every replicate would lie below the curve. The replicates are drawn instead from an estimated assemblage: the undetected species, as many as Chao1 estimates, share the estimated coverage deficit, and the relative abundances of the detected species are lowered to make room for them. Each replicate is a sample of \(N\) individuals from that assemblage, rarefied like the data, and the standard error is the standard deviation over replicates. The bounds describe the assemblage the sample came from, so the interval has a width at \(n = N\) too, where the expectation is \(S_{obs}\).

Hill numbers of order q

The Hill number of order \(q\) of a community with relative abundances \(p_i\) is

\[ {}^{q}D = \left( \sum_{i=1}^{S} p_i^{q} \right)^{1/(1-q)}, \qquad q \ne 1, \]

with the \(q = 1\) case taken as the limit \({}^{1}D = \exp(-\sum_i p_i \log p_i)\). Each \({}^{q}D\) is an effective number of species: the number of equally abundant species that would give the same diversity value. Order 0 is richness, order 1 the exponential of Shannon entropy and order 2 the inverse Simpson concentration. Higher \(q\) down-weights rare species, so the rarefaction curve for \(q = 2\) saturates faster and depends far less on subsample size than the curve for \(q = 0\).

The choice of \(q\) follows from the research question. Richness counts a species seen once and a species seen a thousand times equally, which makes it the order most sensitive to sampling effort and to the rare tail. Shannon diversity weights each species by its abundance and is less affected by the few rarest records. Inverse Simpson is governed almost entirely by the common species and barely moves as effort grows, which makes it a stable comparison when the rare tail is suspected to be noise. Scanning \(q\) from 0 upward on the same data traces a diversity profile, and the steepness of that profile measures how uneven the community is (Accumulating Hill numbers and partitioning diversity).

Practical guidance

  • Keep at least 30 to 50 individuals per site before trusting an individual-based rarefaction. Below that the curve is dominated by the first few draws and the bootstrap interval is wide.

  • Rarefy down to the smallest pool in a comparison, never up.

  • Sample-based curves (mao_tau(), coleman()) need at least 10 to 15 sites before the expectation and its variance are meaningful.

  • Use \(q = 1\) or \(q = 2\) when singletons are suspected to be identification errors; richness (\(q = 0\)) is the order most sensitive to them.

  • Set the cell_size of grid thinning near the spatial scale of autocorrelation. A cell smaller than the spacing between neighbouring sites keeps nearly every site and removes no redundancy; a cell several times that spacing discards most of the data. Thinning gives up sample size to gain independence, and the cell size sets the balance.

  • When sampling effort is already equal across sites, raw richness is directly comparable, and a rarefaction step only discards information.

References

  • Aiello-Lammens, M.E., Boria, R.A., Radosavljevic, A., et al. (2015). spThin: an R package for spatial thinning of species occurrence records for use in ecological niche models. Ecography, 38, 541-545.

  • Chao, A., Gotelli, N.J., Hsieh, T.C., et al. (2014). Rarefaction and extrapolation with Hill numbers: a framework for sampling and estimation in species diversity studies. Ecological Monographs, 84, 45-67.

  • Coleman, B.D., Mares, M.A., Willig, M.R. & Hsieh, Y.H. (1982). Randomness, area, and species richness. Ecology, 63, 1121-1133.

  • Colwell, R.K., Mao, C.X. & Chang, J. (2004). Interpolating, extrapolating, and comparing incidence-based species accumulation curves. Ecology, 85, 2717-2727.

  • Hurlbert, S.H. (1971). The nonconcept of species diversity: a critique and alternative parameters. Ecology, 52, 577-586.