designdist {vegan} | R Documentation

## Design your own Dissimilarities

### Description

You can define your own dissimilarities using terms for shared and total quantities, number of rows and number of columns. The shared and total quantities can be binary, quadratic or minimum terms. In binary terms, the shared component is number of shared species, and totals are numbers of species on sites. The quadratic terms are crossproducts and sums of squares, and minimum terms are sums of parallel minima and row totals.

### Usage

    designdist(x, method = "(A+B-2*J)/(A+B)",
        terms = c("binary", "quadratic", "minimum"), name)

### Arguments

`x` | Input data.
`method` | Equation for your dissimilarities. This can use terms `J` for shared quantity, `A` and `B` for totals, `N` for the number of rows (sites) and `P` for the number of columns (species). The equation also can contain any R functions accepting vector arguments and returning vectors of the same length.
`terms` | How shared and total components are found. For vectors `x` and `y` the `"quadratic"` terms are `J = sum(x*y)`, `A = sum(x^2)`, `B = sum(y^2)`, and `"minimum"` terms are `J = sum(pmin(x,y))`, `A = sum(x)` and `B = sum(y)`, and `"binary"` terms are either of these after transforming data into binary form (shared number of species, and number of species for each row).
`name` | The name you want to use for your index. The default is to combine the `method` equation and `terms` argument.

### Details

Most popular dissimilarity measures in ecology can be expressed with the help of terms `J`, `A` and `B`, and some also involve matrix dimensions `N` and `P`. Some examples you can define in `designdist` are:

`A+B-2*J` | `"quadratic"` | squared Euclidean
`A+B-2*J` | `"minimum"` | Manhattan
`(A+B-2*J)/(A+B)` | `"minimum"` | Bray-Curtis
`(A+B-2*J)/(A+B)` | `"binary"` | Sørensen
`(A+B-2*J)/(A+B-J)` | `"binary"` | Jaccard
`(A+B-2*J)/(A+B-J)` | `"minimum"` | Ružička
`(A+B-2*J)/(A+B-J)` | `"quadratic"` | (dis)similarity ratio
`1-J/sqrt(A*B)` | `"binary"` | Ochiai
`1-J/sqrt(A*B)` | `"quadratic"` | cosine complement
`1-phyper(J-1, A, P-A, B)` | `"binary"` | Raup-Crick

The function `designdist` can implement most dissimilarity indices in `vegdist` or elsewhere, and it also can be used to implement many other indices (some of the examples above are not available in `vegdist`). It also can used to implement indices of beta diversity.

If you want to implement binary dissimilarities based on 2x2 contingency table notation, then a = `J`, b = `A-J`, c = `B-J`, d = `P-A-B+J`, b+c = `A+B-2*J`, and a+b+c = `A+B-J`.

### Value

Function returns an object of class `dist`.

### Note

Function does not use compiled code, and may be slow or use plenty of memory in large data sets. It is very easy to make errors when defining a function by hand. If an index is available in a function using compiled code, it is better to use the canned alternative.

### Author(s)

Jari Oksanen

### See Also

`vegdist`, `dist`.

### Examples

    ## Arrhenius dissimilarity: the value of z in the species-area model
    ## S = c*A^z when combining two sites of equal areas, where S is the
    ## number of species, A is the area, and c and z are model parameters.
    ## The A below is not the area (which cancels out), but number of
    ## species in one of the sites, as defined in designdist().
    data(BCI)
    dis <- designdist(BCI, "(log(A+B-J)-log(A+B)+log(2))/log(2)")
    ## This can be used in clustering or ordination...
    ordiplot(cmdscale(dis))
    ## ... or in analysing beta diversity (without gradients)
    summary(dis)

[Package vegan version 1.8-6 Index]