similarity: Calculate Multivariate Environmental Similarity

View source: R/similarity.R

similarityR Documentation

Calculate Multivariate Environmental Similarity

Description

Calculate Multivariate Environmental Similarity and most dissimilar/similar variables with respect to a reference dataset, for a set of environmental variables.

Usage

similarity(x, ref, full = FALSE)

Arguments

x

a ⁠Raster*⁠, list, matrix, or data.frame where each layer/column/element represents focal values of an environmental variable.

ref

a list, matrix, or data.frame where each column/element represents reference values for an environmental variable (corresponding to those given in x).

full

(logical) should similarity values be returned for all variables? If FALSE (the default), then only the minimum similarity scores across variables will be returned.

Details

similarity uses the MESS algorithm described in Appendix S3 of Elith et al. 2010.

Value

If x is a ⁠Raster*⁠ object, this function returns a list containing:

  • similarity: a RasterStack giving the environmental similarities for each variable in x (only included when full=TRUE);

  • similarity_min: a Raster layer giving the minimum similarity value across all variables for each location (i.e. the MESS);

  • mod: a factor Raster layer indicating which variable was most dissimilar to its reference range (i.e. the MoD map, Elith et al. 2010); and

  • mos: a factor Raster layer indicating which variable was most similar to its reference range.

If x is a list, matrix, or data.frame, the function will return a list as above, but with RasterStack and Raster objects replaced by matrix and vectors.

References

Examples

library(dismo)
library(raster)
ff <- list.files(system.file('ex', package='dismo'), '\\.grd$', 
                 full.names=TRUE )
predictors <- stack(grep('biome', ff, value=TRUE, invert=TRUE))
occ <- read.csv(system.file('ex/bradypus.csv', package='dismo'))[, -1]
ref <- extract(predictors, occ)
mess <- similarity(predictors, ref, full=TRUE)

## Not run: 
library(rasterVis)
library(RColorBrewer)
levelplot(mess$mod, col.regions=brewer.pal(8, 'Set1'))
levelplot(mess$mos, col.regions=brewer.pal(8, 'Set1'))

## End(Not run)

johnbaums/rmaxent documentation built on Oct. 11, 2024, 11:14 a.m.