nicheOverlap: Calculate niche overlap as per Broennimann et al. (2012)

nicheOverlapR Documentation

Calculate niche overlap as per Broennimann et al. (2012)

Description

This function calculates niche overlap between two species.

Usage

nicheOverlap(x1, x2, env, vars, bins = 100, cor = TRUE, densities = FALSE)

Arguments

x1

Data frame, matrix, or any object that can be coerced to a data frame containing environmental data at occurrence sites of a species.

x2

Data frame, matrix, or any object that can be coerced to a data frame containing environmental data at occurrence sites of another species.

env

Either a data frame, matrix, or any object that can be coerced to a data frame containing environmental data at available background sites, or an object of class princomp representing a principal components analysis generated using the princomp function with argument scores = TRUE.

vars

Either a character list naming columns in x1, x2, and x3 to be used as environmental data, or positive integers indexing the columns to be used as environmental data.

bins

Number of bins into which to divide the environmental space (default is 100 on each side).

cor

Logical, if TRUE (default), then the PCA used to construct the environmental space will use the correlation matrix (this is highly recommended if the variables are on different scales). This is ignored if env is an object of class princomp.

densities

Logical. If TRUE, then return not only metrics of niche similarity but also the density matrices (environment, species #1, and species #2).

Value

If densities is FALSE (default), return a vector these named elements:

  • meanDiff: Mean difference between binned, standardized densities of x1 and x2 in environmental space.

  • meanAbsDiff: Mean absolute difference between binned, standardized densities of x1 and x2 (ie, sum(abs(x1 - x2))) in environmental space.

  • rmsd: Root mean squared difference.

  • d: Schoener's D.

  • i: Warren's I.

  • esp: Godsoe's ESP.

  • rho: Correlation between binned, standardized densities of x1 and x2 in environmental space.

  • rankCor: Pearson rank correlation between binned, standardized densities of x1 and x2.

If densities is TRUE, then return a list with a vector of metrics of niche overlap as above, plus three matrices:

  • environDens: Density of available environment.

  • x1density: Density of species #1 in environmental space, normalized to sum to 1 but not normalized by available environment.

  • x2density: Density of species #2 in environmental space, normalized to sum to 1 but not normalized by available environment.

References

This function replicates the procedure presented in Broennimann, O., Fitzpatrick, M.C., Pearman, P.B., Petitpierre, B., Pellissier, L., Yoccoz, N.G., Thuiller, W., Fortin, M-J., Randin, C., Zimmermann, N.E., Graham, C.H., and Guisan, A. 2012. Measuring ecological niche overlap from occurrence and spatial environmental data. Global Ecology and Biogeography 21:481-497.

See Also

compareNiches

Examples

# comparing niches between the common brown leumr (Eulemur fulvus)
# and the red-bellied lemur (Eulemur rubriventer)

data(mad0)
data(lemurs)

# climate data
bios <- c(1, 5, 12, 15)
clim <- raster::getData('worldclim', var='bio', res=10)
clim <- raster::subset(clim, bios)
clim <- raster::crop(clim, mad0)

# occurrence data
occs1 <- lemurs[lemurs$species == 'Eulemur fulvus', ]
occs2 <- lemurs[lemurs$species == 'Eulemur rubriventer', ]

ll <- c('longitude', 'latitude')
plot(mad0)
points(occs1[ , ll])
points(occs2[ , ll], col='red', pch=3)

occsEnv1 <- raster::extract(clim, occs1[ , ll])
occsEnv2 <- raster::extract(clim, occs2[ , ll])

# background sites
bg <- 2000 # too few cells to locate 10000 background points
bgSites <- dismo::randomPoints(clim, 2000)
bgEnv <- extract(clim, bgSites)

vars <- paste0('bio', bios)
nicheOverlap(occsEnv1, occsEnv2, env=bgEnv, vars=vars)


adamlilith/enmSdm documentation built on Jan. 6, 2023, 11 a.m.