Compute Functional Diversity Hill Indices"

About this tutorial

What is this tutorial about?


This tutorial explains how to compute the family of indices presented in Chao et al. (2019) using mFD.


Let's load data and compute functional distance


The data set used to illustrate this tutorial is the fruits dataset based on 25 types of fruits (i.e. species) distributed in 10 fruits baskets (i.e. assemblages). Each fruit is characterized by six traits values summarized in the following table:

| Trait name | Trait measurement | Trait type | Number of classes | Classes code | Unit | |:------------:|:------------------:|:-------------:|:-------------------:|:----------------------------------:|:------:| | Size | Maximal diameter | Ordinal | 5 | 0-1 ; 1-3 ; 3-5 ; 5-10 ; 10-20 | cm | | Plant | Growth form | Categorical | 4 | tree; shrub; vine; forb | NA | | Climate | Climatic niche | Ordinal | 3 | temperate ; subtropical ; tropical | NA | | Seed | Seed type | Ordinal | 3 | none ; pip ; pit | NA | | Sugar | Sugar | Continuous | NA | NA | g/kg | | Use | Use as food | Fuzzy | 3 | raw ; pastry ; jam | % |


We load the three objects used to compute functional framework (for more explanations, see mFD General Workflow):


data("fruits_traits", package = "mFD")

knitr::kable(head(fruits_traits),
      caption = "Species x traits data frame based on the **fruits** dataset")


data("baskets_fruits_weights", package = "mFD")

knitr::kable(as.data.frame(baskets_fruits_weights[1:6, 1:6]), 
             caption = "Species x assemblages matrix based on the **fruits** dataset")


data("fruits_traits_cat", package = "mFD")
knitr::kable(head(fruits_traits_cat), 
             caption = "Traits types based on **fruits & baskets** dataset")


Then, we can compute functional distance using the mFD::funct.dist() function as follows:

USAGE

fruits_gower <- mFD::funct.dist(
  sp_tr         = fruits_traits,
  tr_cat        = fruits_traits_cat,
  metric        = "gower",
  scale_euclid  = "noscale",
  ordinal_var   = "classic",
  weight_type   = "equal",
  stop_if_NA    = TRUE)


Generalisation of Hill numbers for alpha functional diversity


The family of indices presented in Chao et al. (2019) allows computing FD based on pairwise distance between species and their weights in assemblages. This generalization of Hill numbers framework is based on two parameters:


Indices are expressed as effective number of functionally equally distinct species (or virtual functional groups) and could thus be directly compared to taxonomic Hill numbers (including species richness).


NOTE For more details about the properties of Hill numbers FD read Chao et al. (2019) and especially its Figures 1 & 2.


All these indices can be computed with the function mFD::alpha.fd.hill().


Here we start by comparing the 'classical' Rao's quadratic entropy expressed in Hill numbers following Ricotta & Szeidl (2009) which is the special case with q = 2 and tau = "max".


USAGE

baskets_FD2max <- mFD::alpha.fd.hill(
  asb_sp_w = baskets_fruits_weights, 
  sp_dist  = fruits_gower, 
  tau      = "max", 
  q        = 2)


Then, we can compute Hill numbers FD of order 2 computed with tau = "mean" and q = 2 as recommended in Chao et al. (2019)


USAGE

baskets_FD2mean <- mFD::alpha.fd.hill(
  asb_sp_w = baskets_fruits_weights, 
  sp_dist  = fruits_gower, 
  tau      = "mean", 
  q        = 2)


We can now compare these two metrics:

round(cbind(FD2max  = baskets_FD2max$"asb_FD_Hill"[ , 1], 
            FD2mean = baskets_FD2mean$"asb_FD_Hill"[ , 1]), 2)


We can see that FD computed with tau = "max" is less variable (ranging from 1.50 to only 1.86) than FD computed with tau = "min" (ranging from 1.72 to 4.10) illustrating its higher sensitivity to functional differences between species.


NB Note that even with q = 0, weights of species are still accounted for by FD. Hence, if the goal is to compute a richness-like index (i.e. accounting only for distance between species present), function mFD::alpha.fd.hill() should be applied to species occurrence data (coded as 0/1, previously computed using sp.tr.summary) so that all species have the same weight). Species occurrence data can be retrieve through the mFD::asb.sp.summary() function:


USAGE

# Retrieve species occurrences data:
baskets_summary    <- mFD::asb.sp.summary(baskets_fruits_weights)
baskets_fruits_occ <- baskets_summary$"asb_sp_occ"

head(baskets_fruits_occ)

# Compute alpha FD Hill with q = 0:
baskets_FD0mean <- mFD::alpha.fd.hill(
  asb_sp_w = baskets_fruits_occ, 
  sp_dist  = fruits_gower, 
  tau      = "mean", 
  q        = 0)

round(baskets_FD0mean$"asb_FD_Hill", 2)


We can see that baskets with same composition of fruits species have same FD values (e.g basket_1, basket_2 and basket_3)


Generalisation of Hill numbers for beta functional diversity


Framework of Chao et al. (2019) also allows computing beta-diversity, with 2 framework similar to Jaccard and Sorensen ones for taxonomic diversity. The mFD:beta.fd.hill() function computes these indices.


NB Note that total weight of assemblages is affecting computation of functional beta-diversity. Hence if it is does not reflect an ecological pattern (e.g. rather difference in sampling effort), it is recommended to apply mFD::beta.fd.hill() to relative weight of species in assemblages.


# retrieve total weight per basket:
baskets_summary$"asb_tot_w"

# Here baskets all contain 2000g of fruits, we illustrate how to compute...
# relative weights using the output of asb.sp.summary:

baskets_fruits_relw <- baskets_fruits_weights / baskets_summary$"asb_tot_w"
apply(baskets_fruits_relw, 1, sum)


Now we can compute functional beta-diversity of order q = 2 (with tau = "mean" for higher sensitivity) with Jaccard-type index:


USAGE

# Compute index:
baskets_betaq2 <- mFD::beta.fd.hill(
  asb_sp_w  = baskets_fruits_relw, 
  sp_dist   = fruits_gower, 
  q         = 2,
  tau       = "mean", 
  beta_type = "Jaccard")

# Then use the mFD::dist.to.df function to ease visualizing result
mFD::dist.to.df(list_dist = list("FDq2" = baskets_betaq2$"beta_fd_q"$"q2"))

We can see that basket 1 is similar (beta < 0.1) to baskets 2,3,4,5,10 and that it is the most dissimilar to basket 8 (beta > 0.5). Baskets 4 and 5 are highly dissimilar (beta > 0.8) to basket 8.


References




Try the mFD package in your browser

Any scripts or data that you put into this service are public.

mFD documentation built on May 29, 2024, 7:25 a.m.