View source: R/distinctiveness_alt.R
distinctiveness_alt | R Documentation |
Computes functional distinctiveness from a site-species matrix (containing presence-absence or relative abundances) of species with provided functional distance matrix considering only species within a given range in the functional space. Basically species are cutoff when their dissimilarity is above the input threshold. The sites-species matrix should have sites in rows and species in columns, similar to vegan package defaults.
distinctiveness_alt(pres_matrix, dist_matrix, given_range)
pres_matrix |
a site-species matrix (presence-absence or relative abundances), with sites in rows and species in columns |
dist_matrix |
a species functional distance matrix |
given_range |
a numeric indicating the dissimilarity range at which the the other species are considered maximally dissimilar |
The Functional Distinctiveness of a species is the average functional distance from a species to all the other in the given community. It is computed as such:
D_i (T) = Σ_(j = 0, j != i)^N [d_ij/T + θ(d_ij - T) (1 - d_ij/T)] / S - 1
with D_i the functional distinctiveness of species i, N the total number of species in the community and d_ij the functional distance between species i and species j. T is the chosen maximal range considered. The function θ(d_ij - T) is an indicator function that returns 1 when d_ij ≥ T and 0 when d_ij < T. IMPORTANT NOTE: in order to get functional rarity indices between 0 and 1, the distance metric has to be scaled between 0 and 1.
a similar matrix from provided pres_matrix
with Distinctiveness
values in lieu of presences or relative abundances, species absent from
communities will have an NA
value (see Note
section)
Absent species should be coded by 0
or NA
in input matrices.
When a species is alone in its community the functional distinctiveness
cannot be computed (denominator = 0 in formula), and its value is assigned
as NaN
.
For speed and memory efficiency sparse matrices can be used as input of
the function using as(pres_matrix, "dgCMatrix")
from the
Matrix
package.
(see vignette("sparse_matrices", package = "funrar")
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.