Title: | Species Richness and Extrapolation |
---|---|
Description: | Functions for calculating species richness for rarefaction and extrapolation, primarily non-parametric species richness such as jackknife, Chao1, and ACE. Also available are functions for plotting species richness and extrapolation curves, and computing standard diversity and entropy indices. |
Authors: | Eric Archer [aut, cre] |
Maintainer: | Eric Archer <[email protected]> |
License: | GNU General Public License |
Version: | 1.4.2 |
Built: | 2024-11-05 05:59:21 UTC |
Source: | https://github.com/ericarcher/sprex |
Calculate species richness and expected number of species primarily based on algorithms in Colwell, R.K., A. Chao, N.J. Gotelli, S.-Y. Lin, C.X. Mao, R.L. Chazdon, and J.T. Longino. 2012. Models and estimators linking individual-based and sample-based rarefaction, extrapolation and comparison of assemblages. Journal of Plant Ecology 5(1):3-21.
sprex
Calculate the number of unobserved species (f0).
ACE(f) Chao1(f) Clench(f, pct.n = 0.85, num.reps = 100) Swor1(f, N) iChao1(f) jack1(f) jack2(f)
ACE(f) Chao1(f) Clench(f, pct.n = 0.85, num.reps = 100) Swor1(f, N) iChao1(f) jack1(f) jack2(f)
f |
a vector of species frequencies where |
pct.n |
percent of samples to use in bootstrap draws. Must be in range of |
num.reps |
number of random re-orderings of samples to fit curve to. |
N |
population size. |
All functions return a vector containing the estimated number of
species (s.est
), unobserved species (f0
), observed species
(s.obs
), and the total number of samples (n
). Swor1
also returns the standard deviation of s.est
as sd.s.est
.
Eric Archer [email protected]
Chao1, ACE
Colwell, R.K., A. Chao, N.J. Gotelli, S.-Y. Lin, C.X. Mao, R.L. Chazdon, and J.T. Longino. 2012. Models and estimators linking individual-based and sample-based rarefaction, extrapolation and comparison of assemblages. Journal of Plant Ecology 5(1):3-21.
jack1, jack2
Burnham, KP and WS Overton. 1978. Estimation of the size of a closed population when capture probabilities vary among animals. Biometrika 65(3):625-633.
Swor1
Chao, A. and C.-W. Lin. 2012. Nonparametric lower bounds for species richness and shared species richness under sampling without replacement. Biometrics 68:912-921.
iChao1
Chiu, C-H, Wang, Y-T, Walther, BA, and A Chao. 2014. An impro.ved nonparametric lower bound of species richness via a modified Good-Turing frequency formula. Biometrics 70(3):671-682.
clench
Clench, H. 1979. How to make regional lists of butterflies: Some thoughts. Journal of the Lepidopterists' Society 33(4):216-231.
data(osa.second.growth) f <- expand.freqs(osa.second.growth) ace.est <- ACE(f) chao1.est <- Chao1(f) jack1.est <- jack1(f) jack2.est <- jack2(f) swor1.est <- Swor1(f, 20000) ichao1.est <- iChao1(f) clench.est <- Clench(f, num.reps = 50) f0.est <- cbind( ACE = ace.est["f0"], Chao1 = chao1.est["f0"], jack1 = jack1.est["f0"], jack2 = jack2.est["f0"], Swor1 = swor1.est["f0"], iChao1 = ichao1.est["f0"], clench = clench.est["f0"] ) f0.est
data(osa.second.growth) f <- expand.freqs(osa.second.growth) ace.est <- ACE(f) chao1.est <- Chao1(f) jack1.est <- jack1(f) jack2.est <- jack2(f) swor1.est <- Swor1(f, 20000) ichao1.est <- iChao1(f) clench.est <- Clench(f, num.reps = 50) f0.est <- cbind( ACE = ace.est["f0"], Chao1 = chao1.est["f0"], jack1 = jack1.est["f0"], jack2 = jack2.est["f0"], Swor1 = swor1.est["f0"], iChao1 = ichao1.est["f0"], clench = clench.est["f0"] ) f0.est
Create bootstrap assemblage of species.
bootstrap.assemblage(f, f0.func, n.boot = 500, ...)
bootstrap.assemblage(f, f0.func, n.boot = 500, ...)
f |
a vector of species frequencies where |
f0.func |
function calculating the unobserved number of
species ( |
n.boot |
number of bootstrap replicates. |
... |
other arguments to |
a list of bootstrap replicates of species frequencies.
Eric Archer [email protected]
Chao, A., N.J. Gotelli, T.C. Hsieh, E.L. Sander, K.H. Ma, R.K. Colwell, and A.M. Ellison. 2014. Rarefaction and extrapolation with Hill numbers: a framework for sampling and estimation in species diversity studies. Ecological Monographs 84(1):45-67.
Calculate the components of a species discovery curve.
discovery.curve( f, f0.func, max.x = sum(f * 1:length(f)), n.pts = 100, ci = 0.95, plot = TRUE, ... )
discovery.curve( f, f0.func, max.x = sum(f * 1:length(f)), n.pts = 100, ci = 0.95, plot = TRUE, ... )
f |
a vector of species frequencies where |
f0.func |
function to use to calculate |
max.x |
the maximum number of samples to calculate the curve for.
Defaults to the sample size of |
n.pts |
number of points between 0 and |
ci |
size of the confidence interval (0.5:1). |
plot |
plot the curve? |
... |
other arguments to |
a list with:
f.stats |
a named vector from |
curve |
a |
Eric Archer [email protected]
Colwell, R.K., A. Chao, N.J. Gotelli, S.-Y. Lin, C.X. Mao, R.L. Chazdon, and J.T. Longino. 2012. Models and estimators linking individual-based and sample-based rarefaction, extrapolation and comparison of assemblages. Journal of Plant Ecology 5(1):3-21.
data(osa.old.growth) f <- expand.freqs(osa.old.growth) d <- discovery.curve(f, f0.func = Chao1, max.x = 1200) print(str(d))
data(osa.old.growth) f <- expand.freqs(osa.old.growth) d <- discovery.curve(f, f0.func = Chao1, max.x = 1200) print(str(d))
Calculate common diversity and entropy indices.
diversity( x, type = c("effective.number", "richness", "shannon", "simpson", "gini.simpson", "unb.gini", "eveness.simpson", "eveness.pielou", "inv.simpson", "renyi", "hill"), q = NULL )
diversity( x, type = c("effective.number", "richness", "shannon", "simpson", "gini.simpson", "unb.gini", "eveness.simpson", "eveness.pielou", "inv.simpson", "renyi", "hill"), q = NULL )
x |
vector or matrix of values (character, factor) representing a class, from which proportions will be computed. If numeric, values will be converted to proportions. If a matrix, indices will be computed for all columns. |
type |
type of index to compute. See Details for descriptions.
If |
q |
order of Hill number (must be >= 0). |
if a vector is supplied for x
, a single value for the chosen
type of index. If a matrix, a vector values for each column.
Available indices for type
are:
the number of observed classes (non-NA
and frequency > 0)
exponent of Hill number of order 1
Shannon entropy
Simpson concentration
Gini-Simpson index (= 1 - Simpson concentration)
Inverse Simpson concentration
unbiased Gini-Simpson index with correction for small sample sizes
Simpson eveness
Pielou eveness
Renyi entropy
Hill number
Eric Archer [email protected]
x <- sample(letters[1:4], 100, replace = TRUE, p = c(1, 2, 3, 4)) types <- c("richness", "effective.number", "shannon", "simpson", "inv.simpson", "gini.simpson", "unb.gini", "eveness.simpson", "eveness.pielou" ) sapply(types, function(tp) diversity(x, type = tp)) # hill numbers with increasing order order <- 0:5 hill.num <- sapply(order, function(q) diversity(x, type = "hill", q = q)) hill.num plot(order, hill.num, type = "b") # a matrix of frequencies spp.freq <- cbind( sample(letters[1:4], 100, replace = TRUE, p = c(1, 1, 1, 4)), sample(letters[1:4], 100, replace = TRUE, p = c(4, 1, 1, 1)), sample(letters[1:4], 100, replace = TRUE, p = c(1, 1, 1, 1)) ) diversity(spp.freq, type = "eff")
x <- sample(letters[1:4], 100, replace = TRUE, p = c(1, 2, 3, 4)) types <- c("richness", "effective.number", "shannon", "simpson", "inv.simpson", "gini.simpson", "unb.gini", "eveness.simpson", "eveness.pielou" ) sapply(types, function(tp) diversity(x, type = tp)) # hill numbers with increasing order order <- 0:5 hill.num <- sapply(order, function(q) diversity(x, type = "hill", q = q)) hill.num plot(order, hill.num, type = "b") # a matrix of frequencies spp.freq <- cbind( sample(letters[1:4], 100, replace = TRUE, p = c(1, 1, 1, 4)), sample(letters[1:4], 100, replace = TRUE, p = c(4, 1, 1, 1)), sample(letters[1:4], 100, replace = TRUE, p = c(1, 1, 1, 1)) ) diversity(spp.freq, type = "eff")
Expand a matrix or data.frame of species frequencies to full vector.
expand.freqs(freq.mat)
expand.freqs(freq.mat)
freq.mat |
a two column matrix or data.frame where the first column is the number of samples, and the second column is the number of species represented by with that many samples. |
a vector(f
) of species frequencies where each element
(f[i]
) is the number of species represented by only i
samples.
Eric Archer [email protected]
data(osa.old.growth) f <- expand.freqs(osa.old.growth) f
data(osa.old.growth) f <- expand.freqs(osa.old.growth) f
Calculate the expected number of species for a given sample size.
expected.num.species(m, f, f0.func, ...)
expected.num.species(m, f, f0.func, ...)
m |
number of samples. |
f |
a vector of species frequencies where |
f0.func |
a function that computes the number of unobserved species (f0). |
... |
other arguments to |
a vector or matrix (depending on whether m
is a scalar or vector,
respectively) of the estimated number of species (s.ind
) seen
in m
samples, and the standard deviation (sd.s.ind
).
Eric Archer [email protected]
Eqns 4, 5, 9, and 10 in Colwell, R.K., A. Chao, N.J. Gotelli, S.-Y. Lin, C.X. Mao, R.L. Chazdon, and J.T. Longino. 2012. Models and estimators linking individual-based and sample-based rarefaction, extrapolation and comparison of assemblages. Journal of Plant Ecology 5(1):3-21.
data(osa.old.growth) f <- expand.freqs(osa.old.growth) expected.num.species(60, f = f, f0.func = Chao1) expected.num.species(c(60, 70, 75), f = f, f0.func = Chao1)
data(osa.old.growth) f <- expand.freqs(osa.old.growth) expected.num.species(60, f = f, f0.func = Chao1) expected.num.species(c(60, 70, 75), f = f, f0.func = Chao1)
Number of observed species and samples in species frequency vector.
f.stats(f)
f.stats(f)
f |
a vector of species frequencies where |
a vector of the number of observed species (s.obs
),
and the total number of samples (n
).
Eric Archer [email protected]
data(osa.second.growth) f <- expand.freqs(osa.second.growth) f.stats(f)
data(osa.second.growth) f <- expand.freqs(osa.second.growth) f.stats(f)
Calculate the additional number of samples (individuals) to required to observe a given proportion of the total number of species.
num.samples.required(g, f, f0.func, ...)
num.samples.required(g, f, f0.func, ...)
g |
propotion of total number of species. |
f |
a vector of species frequencies where |
f0.func |
a function that computes the number of unobserved species (f0). |
... |
other arguments to |
a vector containing of the estimated additional number of samples
(m.g
) required to observe g
percent of the total number
of species.
Eric Archer [email protected]
Eqn 12 in Chao, A., R.K. Colwell, C.-W. Lin, and N.J. Gotelli. 2009.
Sufficient sampling for asymptotic minimum species richness estimators.
Ecology 90(4):1125-1133.
Eqn 11 in Colwell, R.K., A. Chao, N.J. Gotelli, S.-Y. Lin,
C.X. Mao, R.L. Chazdon, and J.T. Longino. 2012. Models and estimators
linking individual-based and sample-based rarefaction, extrapolation and
comparison of assemblages. Journal of Plant Ecology 5(1):3-21.
data(osa.old.growth) f <- expand.freqs(osa.old.growth) num.samples.required(0.6, f = f, f0.func = Chao1)
data(osa.old.growth) f <- expand.freqs(osa.old.growth) num.samples.required(0.6, f = f, f0.func = Chao1)
Matrices of the number of beetle species (fi
) occuring
i
times in a survey.
data(osa.old.growth) data(osa.second.growth)
data(osa.old.growth) data(osa.second.growth)
Janzen DH (1973) Sweep samples of tropical foliage insects:
effects of seasons, vegetation types, elevation, time of day,
and insularity. Ecology 54:687-708.
Janzen DH (1973) Sweep samples of tropical foliage insects:
description of study sites, with data on species abundances and size
distributions. Ecology 54:659-86.
Calculate the percent of overlap between two species estimate distributions where the larger sample size has been rarefied to match the smaller sample size.
rarefaction.overlap(x, y, f0.func, n.rare = NULL, ...)
rarefaction.overlap(x, y, f0.func, n.rare = NULL, ...)
x , y
|
two vectors of species frequencies where the |
f0.func |
function to use to calculate f0. Can be |
n.rare |
sample size to rarefy both populations to. Must be <= the minimum
sample size. If |
... |
other arguments to |
Calculates the expected number of species and the standard
deviation for the smaller sample size of x
and y
using
the frequency distributions of each. The function then fits a gamma
distribution to each of these estimates, and returns the percent of overlap
as the integral of the mininum value of the PDF for the two distributions.
Integration takes place from 0 to the largest quantile representing
0.99999 of either distribution.
a vector with the percent of overlap between the two distributions,
the sample size, and species estimates for the x
and
y
vectors.
Eric Archer [email protected]
Colwell, R.K., A. Chao, N.J. Gotelli, S.-Y. Lin, C.X. Mao, R.L. Chazdon, and J.T. Longino. 2012. Models and estimators linking individual-based and sample-based rarefaction, extrapolation and comparison of assemblages. Journal of Plant Ecology 5(1):3-21.
data(osa.old.growth) data(osa.second.growth) x <- expand.freqs(osa.old.growth) y <- expand.freqs(osa.second.growth) rarefaction.overlap(x, y, Chao1)
data(osa.old.growth) data(osa.second.growth) x <- expand.freqs(osa.old.growth) y <- expand.freqs(osa.second.growth) rarefaction.overlap(x, y, Chao1)
Create vector of species frequencies from vector of sample frequencies.
sample.to.species.freq(x, min.f = NULL)
sample.to.species.freq(x, min.f = NULL)
x |
a vector where |
min.f |
minimum size of return vector. Return vector is zero-padded up to this length if it would normally be shorter. |
a vector(f
) of species frequencies where f[i]
is the
number of species represented by only i
samples.
Eric Archer [email protected]
species.to.sample.freq
x <- sample(1:20, 20, rep = TRUE) f <- sample.to.species.freq(x) print(x) print(f)
x <- sample(1:20, 20, rep = TRUE) f <- sample.to.species.freq(x) print(x) print(f)
Create vector of sample frequencies from vector of species frequencies.
species.to.sample.freq(f)
species.to.sample.freq(f)
f |
a vector of species frequencies where |
a vector(x
) where x[i]
is of the number of samples
in the i
-th species.
Eric Archer [email protected]
sample.to.species.freq
data(osa.old.growth) f <- expand.freqs(osa.old.growth) x <- species.to.sample.freq(f) print(f) print(x)
data(osa.old.growth) f <- expand.freqs(osa.old.growth) x <- species.to.sample.freq(f) print(f) print(x)