R: Measuring Functional Diversity from Multiple Traits, and...
FD-package
R Documentation
Measuring Functional Diversity from Multiple Traits, and Other Tools for Functional Ecology
Description
FD is a package to compute different multidimensional functional diversity (FD) indices. It implements a distance-based framework to measure FD that allows any number and type of functional traits, and can also consider species relative abundances. It also contains other tools for functional ecologists (e.g. maxent).
Details
Package:
FD
Type:
Package
Version:
1.0-12
Date:
2014-08-19
License:
GPL-2
LazyLoad:
yes
LazyData:
yes
FD computes different multidimensional FD indices. To compute FD indices, a species-by-trait(s) matrix is required (or at least a species-by-species distance matrix). gowdis computes the Gower dissimilarity from different trait types (continuous, ordinal, nominal, or binary), and tolerates NAs. It can treat ordinal variables as described by Podani (1999), and can handle asymetric binary variables and variable weights. gowdis is called by dbFD, the main function of FD.
Botta-Dukát, Z. (2005) Rao's quadratic entropy as a measure of functional diversity based on multiple traits. Journal of Vegetation Science16:533-540.
# examples with a dummy dataset
ex1 <- gowdis(dummy$trait)
ex1
ex2 <- functcomp(dummy$trait, dummy$abun)
ex2
ex3 <- dbFD(dummy$trait, dummy$abun)
ex3
# examples with real data from New Zealand short-tussock grasslands
# these examples may take a few seconds to a few minutes each to run
ex4 <- gowdis(tussock$trait)
ex5 <- functcomp(tussock$trait, tussock$abun)
# 'lingoes' correction used because 'sqrt' does not work in that case
ex6 <- dbFD(tussock$trait, tussock$abun, corr = "lingoes")
## Not run:
# ward clustering to compute FGR, cailliez correction
ex7 <- dbFD(tussock$trait, tussock$abun, corr = "cailliez",
calc.FGR = TRUE, clust.type = "ward")
# choose 'g' for number of groups
# 6 groups seems to make good ecological sense
ex7
# however, calinksi criterion in 'kmeans' suggests
# that 6 groups may not be optimal
ex8 <- dbFD(tussock$trait, tussock$abun, corr = "cailliez",
calc.FGR = TRUE, clust.type = "kmeans", km.sup.gr = 10)
## End(Not run)
Results
R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
> library(FD)
Loading required package: ade4
Loading required package: ape
Loading required package: geometry
Loading required package: magic
Loading required package: abind
Loading required package: vegan
Loading required package: permute
Loading required package: lattice
This is vegan 2.4-0
Attaching package: 'vegan'
The following object is masked from 'package:ade4':
cca
> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/FD/FD-package.Rd_%03d_medium.png", width=480, height=480)
> ### Name: FD-package
> ### Title: Measuring Functional Diversity from Multiple Traits, and Other
> ### Tools for Functional Ecology
> ### Aliases: FD-package FD
> ### Keywords: package
>
> ### ** Examples
>
> # examples with a dummy dataset
>
> ex1 <- gowdis(dummy$trait)
> ex1
sp1 sp2 sp3 sp4 sp5 sp6 sp7
sp2 0.2181884
sp3 0.5240052 0.6678082
sp4 0.6737443 0.5610028 0.8225701
sp5 0.5291113 0.8145699 0.4862253 0.4843264
sp6 0.6100161 0.5932587 0.2784736 0.7073925 0.6067323
sp7 0.4484235 0.6863374 0.4848663 0.5575126 0.3023416 0.6187844
sp8 0.4072834 0.2039443 0.5958904 0.2390962 0.5585525 0.4470207 0.7030186
>
> ex2 <- functcomp(dummy$trait, dummy$abun)
> ex2
num1 num2 fac1 fac2 ord1 ord2 bin1 bin2
com1 5.887500 4.037500 C X 2 6 0 0
com2 4.212500 5.562500 B Z 1 3 0 1
com3 5.716667 6.166667 A Z 1 3 0 1
com4 9.000000 2.575000 C Y 5 3 1 1
com5 4.500000 3.050000 C X 2 7 0 0
com6 5.095238 5.528571 C Z 2 1 0 1
com7 7.009091 5.427273 A Z 3 1 0 1
com8 5.245455 3.572727 C X 2 6 1 0
com9 6.870000 4.245455 A X 3 2 0 1
com10 7.427273 3.783333 B X 3 2 1 0
>
> ex3 <- dbFD(dummy$trait, dummy$abun)
Species x species distance matrix was not Euclidean. 'sqrt' correction was applied.
FEVe: Could not be calculated for communities with <3 functionally singular species.
FRic: To respect s > t, FRic could not be calculated for communities with <3 functionally singular species.
FRic: Dimensionality reduction was required. The last 5 PCoA axes (out of 7 in total) were removed.
FRic: Quality of the reduced-space representation (based on corrected distance matrix) = 0.6108352
FDiv: Could not be calculated for communities with <3 functionally singular species.
> ex3
$nbsp
com1 com2 com3 com4 com5 com6 com7 com8 com9 com10
4 3 3 2 3 5 3 4 5 4
$sing.sp
com1 com2 com3 com4 com5 com6 com7 com8 com9 com10
4 3 3 2 3 5 3 4 5 4
$FRic
com1 com2 com3 com4 com5 com6
0.174201349 0.102097174 0.002157642 NA 0.143151204 0.231083703
com7 com8 com9 com10
0.073683375 0.174220613 0.337446205 0.228904118
$qual.FRic
[1] 0.6108352
$FEve
com1 com2 com3 com4 com5 com6 com7 com8
0.8432334 0.4628635 0.8659657 NA 0.9081209 0.8651734 0.7681991 0.7606650
com9 com10
0.7994638 0.4944601
$FDiv
com1 com2 com3 com4 com5 com6 com7 com8
0.8429221 0.8593250 0.6303031 NA 0.7631346 0.8966687 0.8356095 0.8681163
com9 com10
0.7015118 0.9712554
$FDis
com1 com2 com3 com4 com5 com6 com7 com8
0.3481687 0.1670560 0.2375808 0.1146261 0.3211366 0.3302330 0.2532751 0.2877931
com9 com10
0.3421687 0.3503927
$RaoQ
com1 com2 com3 com4 com5 com6 com7
0.12835440 0.04063622 0.06497224 0.03003235 0.11858388 0.11738479 0.07868047
com8 com9 com10
0.09308505 0.12431265 0.12490783
$CWM
num1 num2 fac1 fac2 ord1 ord2 bin1 bin2
com1 5.887500 4.037500 C X 2 6 1 0
com2 4.212500 5.562500 B Z 1 3 0 1
com3 5.716667 6.166667 A Z 1 3 0 1
com4 9.000000 2.575000 C Y 5 3 1 1
com5 4.500000 3.050000 C X 2 6 0 0
com6 5.095238 5.528571 C Z 2 1 0 1
com7 7.009091 5.427273 A Z 3 1 0 1
com8 5.245455 3.572727 C X 2 6 1 0
com9 6.870000 4.245455 A X 3 2 0 1
com10 7.427273 3.783333 B X 3 2 1 1
>
> # examples with real data from New Zealand short-tussock grasslands
> # these examples may take a few seconds to a few minutes each to run
>
> ex4 <- gowdis(tussock$trait)
>
> ex5 <- functcomp(tussock$trait, tussock$abun)
>
> # 'lingoes' correction used because 'sqrt' does not work in that case
> ex6 <- dbFD(tussock$trait, tussock$abun, corr = "lingoes")
Species x species distance matrix was not Euclidean. Lingoes correction was applied.
FRic: Dimensionality reduction was required. The last 40 PCoA axes (out of 51 in total) were removed.
FRic: Quality of the reduced-space representation (based on corrected distance matrix) = 0.5624752
>
> ## Not run:
> ##D # ward clustering to compute FGR, cailliez correction
> ##D ex7 <- dbFD(tussock$trait, tussock$abun, corr = "cailliez",
> ##D calc.FGR = TRUE, clust.type = "ward")
> ##D # choose 'g' for number of groups
> ##D # 6 groups seems to make good ecological sense
> ##D ex7
> ##D
> ##D # however, calinksi criterion in 'kmeans' suggests
> ##D # that 6 groups may not be optimal
> ##D ex8 <- dbFD(tussock$trait, tussock$abun, corr = "cailliez",
> ##D calc.FGR = TRUE, clust.type = "kmeans", km.sup.gr = 10)
> ## End(Not run)
>
>
>
>
>
> dev.off()
null device
1
>