Learn R Programming

labdsv (version 1.2-0)

dsvdis: Dissimilarity Indices and Distance Measures

Description

This function provides a set of alternative dissimilarity indices and distance metrics for classification and ordination, including weighting by species (columns) and shortest-path adjustment for dissimilarity indices.

Usage

dsvdis(x,index,weight=rep(1,ncol(x)),step=0.0,
       diag=FALSE, upper=FALSE)

Arguments

x
a matrix of observations, samples as rows and variables as columns
index
a specific dissimilarity or distance index (see details below)
weight
a vector of weights for species (columns)
step
a threshold dissimilarity to initiate shortest-path adjustment
diag
a switch to control returning diagonal (default=FALSE)
upper
a switch to control returning upper (TRUE) or lower (FALSE) triangle

Value

  • Returns an object of class "dist", equivalent to that from dist.

Details

The function calculates dissimilarity or distance between rows of a matrix of observations according to a specific index. Three indices convert the data to presence/absence automatically. In contingency table notation, they are:

ll{ steinhaus $1 - a / (a + b + c)$ sorensen $1 - 2a / (2a + b +c)$ ochiai $1 - a / \sqrt{(a+b) \times (a+c)}$ }

Others are quantitative. For variable i in samples x and y:

ll{ ruzicka $1 - \sum min(x_i,y_i) / \sum max(x_i,y_i)$ bray/curtis $1 - \sum[2 \times min(x_i,y_i)] / \sum x_i + y_i$ roberts $1 - [(x_i+y_i) \times (min(x_i,y_i) / max(x_i,y_i)] / (x_i + y_i)$ chisq $(exp - obs) / \sqrt(exp)$ } The weights allow the assignment of weights to individual species in the calculation of plot-to-plot similarity. The weights can be assigned by life-form, indicator value, or for other investigator specific reasons. Weights should be in the interval [0,1]. The default (rep(1,ncol(x)) is to set all species = 1.

The threshold dissimilarity (step) sets all values greater than "step" to 9999.9 and then solves for the shortest path distance connecting plots to other non-9999.9 values in the matrix. Step = 0.0 (the default) is a flag for "no shortest-path correction".

References

http://ecology.msu.montana.edu:/labdsv/R

See Also

dist, vegdist

Examples

Run this code
data(bryceveg)   # returns a dataframe called "bryceveg"
    dis.ochiai <- dsvdis(bryceveg,index="ochiai")
    dis.bc <- dsvdis(bryceveg,index="bray/curtis")

Run the code above in your browser using DataLab