Learn R Programming

sads (version 0.2.2)

rsad: Poisson and negative binomial sampling of a species abundance distribution

Description

A given number of realizations of a probability distribution (species abundances in a community) is sampled by a Poisson or Negative Binomial process.

Usage

rsad(S, frac, sad, Pois.samp = TRUE, k , zeroes = FALSE, ssize=1, ...)

Arguments

S
positive integer; number of species in the community, which is the number of random deviates generated by the probability distribution given by argument sad
frac
single numeric 0 < frac <= 1<="" code="">; fraction of the community sampled
sad
character; root name of community sad distribution - e.g., lnorm for the lognormal distribution rlnorm; geom for the geometric distribution rgeom. Note that at the present moment only the following dis
Pois.samp
logical; if TRUE the sampling process is Poisson (independent sampling of individuals); if FALSE negative binomial sampling is used to simulate aggregation of individuals in sampling units.
k
positive; size parameter for the sampling binomial negative.
zeroes
logical; should zero values be included in the returned vector?
ssize
positive integer; sample size: number of draws taken from the community.
...
named arguments to be passed to the probability function defined by the argument sad.

Value

  • if ssize=1 a vector of (zero truncated) abundances in the sample; if ssize>1 a data frame with sample identification, species identification, and (zero truncated) abundances.

Details

This function simulates a random sample taken from a community with S species. The expected species abundances in the sampled community follow a probability distribution given by the argument sad. A fraction frac of the community is sampled, thus the expected abundance in the sample of each species is frac*n, where n is the species' expected abundance in the community.

Two sampling processes can be simulated: Poisson, where individuals are sampled independently, and negative binomial, where individuals are aggregated over sampling units.

In general terms, this function takes a Poisson or negative binomial sampling with replacement of a vector of S realizations of a random variable, with the sampling intensity given by frac. The resulting values are realizations of a Poisson (or a Negative Binomial) random variable where the parameter that corresponds to the mean (=expected value of the variable) follows a probability distribution given by the argument sad.

References

Pielou, E.C. 1977. Mathematical Ecology. New York: John Wiley and Sons. Green,J. and Plotkin, J.B. 2007 A statistical theory for sampling species abundances. Ecology Letters 10:1037--1045

See Also

dpoix, dpoig and dpoilog for examples of compound Poisson probability distributions like those simulated by rsad.

Examples

Run this code
##A Poisson sample from a community with a lognormal sad
samp2 <- rsad(S = 100, frac=0.1, sad="lnorm", meanlog=5, sdlog=2)
## Preston plot
plot(octav(samp2))
## Once this is a Poisson sample of a lognormal community, the abundances
## in the sample should follow a Poisson-lognormal distribution.
## Adds line of theoretical Poisson-lognormal with
## mu=meanlog+log(frac) and sigma=sdlog)
## Predicted by the theoretical Poisson-lognormal truncated at zero
samp2.pred <- octavpred(samp2, sad="poilog", coef= list(mu=5+log(0.1), sig=2), trunc=0)
## Adding the line in the Preston plot
lines(samp2.pred)

Run the code above in your browser using DataLab