calc_comm_div_ci: Compute non-parametric confidence intervals across diversity...

View source: R/mobr_boxplots.R

calc_comm_div_ciR Documentation

Compute non-parametric confidence intervals across diversity indices.

Description

This function take a list of community matrices and returns the central tendency and the confidence interval for each diversity index of interest across that list of communities.

Usage

calc_comm_div_ci(
  samples,
  cent_stat = "median",
  ci = c(0.025, 0.975),
  index,
  effort = NA,
  extrapolate = TRUE,
  return_NA = FALSE,
  rare_thres = 0.05,
  scales = c("alpha", "gamma", "beta"),
  PIE_replace = FALSE,
  C_target_gamma = NA,
  ...
)

Arguments

samples

a list of community matrices (i.e., the output of get_samples)

cent_stat

a string that is either 'mean' or 'median' which specifies the measure of central tendency. Defaults to 'median'.

ci

a numeric vector of two numbers specifying the lower and upper quantiles of the distribution to return. The default is to report the 0.025 and 0.975 quantiles in other words a 95 percent interval.

index

The calculated biodiversity indices. The options are

  • N ... Number of individuals (total abundance)

  • S ... Number of species

  • S_n ... Rarefied or extrapolated number of species for n individuals

  • S_C ... Estimate species richness of a given level of coverage by C_target_gamma

  • S_asymp ... Estimated asymptotic species richness

  • f_0 ... Estimated number of undetected species

  • pct_rare ... The percent of rare species as defined by rare_thres

  • PIE ... Hurlbert's PIE (Probability of Interspecific Encounter)

  • S_PIE ... Effective number of species based on PIE

See Details for additional information on the biodiversity statistics.

effort

The standardized number of individuals used for the calculation of rarefied species richness. This must be a single integer.

extrapolate

Boolean which specifies if richness should be extrapolated when effort is larger than the number of individuals using the chao1 method (Chao 1984, 1987). Defaults to TRUE.

return_NA

Boolean in which the rarefaction function returns the observed S when effort is larger than the number of individuals. If set to TRUE then NA is returned. Note that this argument is only relevant when extrapolate = FALSE.

rare_thres

The threshold that determines how the metric pct_rare is computed. It can range from (0, 1] and defaults to 0.05 which specifies that any species with less than or equal to 5 abundance in a sample is considered rare. It can also be specified as "N/S" which results in using average abundance as the threshold which McGill (2011) found to have the best small sample behavior.

scales

The scales to compute the diversity indices for:

  • alpha ... for each row of the site x species community matrix

  • gamma ... for the entire site x species community matrix

  • beta ... the ratio of diversity at the gamma and alpha scales.

Defaults to all three scales: c('alpha', 'gamma', 'beta')

PIE_replace

Used for PIE and SPIE. If TRUE, sampling with replacement is used. Otherwise, sampling without replacement (default).

C_target_gamma

When computing coverage based richness (S_C) then this argument can be used to specify the coverage to be used for the gamma scale richness estimate. This defaults to NA in which case the target cover is computed by calc_C_target (i.e., the largest allowable sample size).

...

additional arguments that can be passed to calc_div

Details

The measure of central tendency can be the median (default) or mean, and the range of the confidence interval can be specified but defaults to a 95 confidence interval.

Value

a data.frame that has the lower, middle, and upper quantiles of the sampled distribution of each diversity index.

See Also

get_samples for generating samples, and calc_comm_div for the calculation of diversity indices.

Examples

data(tank_comm)
samples <- get_samples(tank_comm, algo = 'loo')
calc_comm_div_ci(samples, index = 'S_PIE')
samples <- get_samples(tank_comm, algo = 'boot', n_boot = 20)
calc_comm_div_ci(samples, index = 'S_PIE')
# compute ci for average diversity (rather than median)
calc_comm_div_ci(samples, index = 'S_PIE', cent_stat = 'avg')

MoBiodiv/mobr documentation built on Oct. 26, 2024, 10:51 a.m.