nicheOverlap | R Documentation |
This function calculates niche overlap between two species.
nicheOverlap(x1, x2, env, vars, bins = 100, cor = TRUE, densities = FALSE)
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 |
vars |
Either a character list naming columns in |
bins |
Number of bins into which to divide the environmental space (default is 100 on each side). |
cor |
Logical, if |
densities |
Logical. If |
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.
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.
compareNiches
# 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.