Generic function for calculating subcommunity-level diversity.
subdiv(data, qs)
# S4 method for powermean
subdiv(data, qs)
# S4 method for relativeentropy
subdiv(data, qs)
# S4 method for metacommunity
subdiv(data, qs)
matrix
of mode numeric
; containing diversity
components
vector
of mode numeric
containing q values
subdiv()
returns a standard output of class rdiv
data
may be input as one of three different classes:
powermean
: raw or normalised metacommunity alpha, rho or gamma
diversity components; will calculate subcommunity-level raw or normalised
metacommunity alpha, rho or gamma diversity
relativeentropy
: raw or normalised metacommunity beta
diversity components; will calculate subcommunity-level raw or normalised
metacommunity beta diversity
metacommunity
: will calculate all subcommunity measures of
diversity
Reeve, R., T. Leinster, C. Cobbold, J. Thompson, N. Brummitt, S. Mitchell, and L. Matthews. 2016. How to partition diversity. arXiv 1404.6520v3:1–9.
# Define metacommunity
pop <- data.frame(a = c(1,3), b = c(1,1))
row.names(pop) <- paste0("sp", 1:2)
pop <- pop/sum(pop)
meta <- metacommunity(pop)
# Calculate subcommunity gamma diversity (takes the power mean)
g <- raw_gamma(meta)
subdiv(g, 0:2)
#> measure q type_level type_name partition_level partition_name diversity
#> 1 gamma 0 types subcommunity a 1.875000
#> 2 gamma 0 types subcommunity b 2.250000
#> 3 gamma 1 types subcommunity a 1.783811
#> 4 gamma 1 types subcommunity b 2.121320
#> 5 gamma 2 types subcommunity a 1.714286
#> 6 gamma 2 types subcommunity b 2.000000
#> dat_id transformation normalised k max_d
#> 1 naive NA NA NA NA
#> 2 naive NA NA NA NA
#> 3 naive NA NA NA NA
#> 4 naive NA NA NA NA
#> 5 naive NA NA NA NA
#> 6 naive NA NA NA NA
# Calculate subcommunity beta diversity (takes the relative entropy)
b <- raw_beta(meta)
subdiv(b, 0:2)
#> measure q type_level type_name partition_level partition_name diversity
#> 1 raw beta 0 types subcommunity a 0.6666667
#> 2 raw beta 0 types subcommunity b 0.3333333
#> 3 raw beta 1 types subcommunity a 0.6777015
#> 4 raw beta 1 types subcommunity b 0.3535534
#> 5 raw beta 2 types subcommunity a 0.6875000
#> 6 raw beta 2 types subcommunity b 0.3750000
#> dat_id transformation normalised k max_d
#> 1 naive NA NA NA NA
#> 2 naive NA NA NA NA
#> 3 naive NA NA NA NA
#> 4 naive NA NA NA NA
#> 5 naive NA NA NA NA
#> 6 naive NA NA NA NA
# Calculate all measures of subcommunity diversity
subdiv(meta, 0:2)
#> measure q type_level type_name partition_level partition_name
#> 1 raw alpha 0 types subcommunity a
#> 2 raw alpha 0 types subcommunity b
#> 3 raw alpha 1 types subcommunity a
#> 4 raw alpha 1 types subcommunity b
#> 5 raw alpha 2 types subcommunity a
#> 6 raw alpha 2 types subcommunity b
#> 7 normalised alpha 0 types subcommunity a
#> 8 normalised alpha 0 types subcommunity b
#> 9 normalised alpha 1 types subcommunity a
#> 10 normalised alpha 1 types subcommunity b
#> 11 normalised alpha 2 types subcommunity a
#> 12 normalised alpha 2 types subcommunity b
#> 13 raw beta 0 types subcommunity a
#> 14 raw beta 0 types subcommunity b
#> 15 raw beta 1 types subcommunity a
#> 16 raw beta 1 types subcommunity b
#> 17 raw beta 2 types subcommunity a
#> 18 raw beta 2 types subcommunity b
#> 19 normalised beta 0 types subcommunity a
#> 20 normalised beta 0 types subcommunity b
#> 21 normalised beta 1 types subcommunity a
#> 22 normalised beta 1 types subcommunity b
#> 23 normalised beta 2 types subcommunity a
#> 24 normalised beta 2 types subcommunity b
#> 25 raw rho 0 types subcommunity a
#> 26 raw rho 0 types subcommunity b
#> 27 raw rho 1 types subcommunity a
#> 28 raw rho 1 types subcommunity b
#> 29 raw rho 2 types subcommunity a
#> 30 raw rho 2 types subcommunity b
#> 31 normalised rho 0 types subcommunity a
#> 32 normalised rho 0 types subcommunity b
#> 33 normalised rho 1 types subcommunity a
#> 34 normalised rho 1 types subcommunity b
#> 35 normalised rho 2 types subcommunity a
#> 36 normalised rho 2 types subcommunity b
#> 37 gamma 0 types subcommunity a
#> 38 gamma 0 types subcommunity b
#> 39 gamma 1 types subcommunity a
#> 40 gamma 1 types subcommunity b
#> 41 gamma 2 types subcommunity a
#> 42 gamma 2 types subcommunity b
#> diversity dat_id transformation normalised k max_d
#> 1 3.0000000 naive NA NA NA NA
#> 2 6.0000000 naive NA NA NA NA
#> 3 2.6321480 naive NA NA NA NA
#> 4 6.0000000 naive NA NA NA NA
#> 5 2.4000000 naive NA NA NA NA
#> 6 6.0000000 naive NA NA NA NA
#> 7 2.0000000 naive NA NA NA NA
#> 8 2.0000000 naive NA NA NA NA
#> 9 1.7547654 naive NA NA NA NA
#> 10 2.0000000 naive NA NA NA NA
#> 11 1.6000000 naive NA NA NA NA
#> 12 2.0000000 naive NA NA NA NA
#> 13 0.6666667 naive NA NA NA NA
#> 14 0.3333333 naive NA NA NA NA
#> 15 0.6777015 naive NA NA NA NA
#> 16 0.3535534 naive NA NA NA NA
#> 17 0.6875000 naive NA NA NA NA
#> 18 0.3750000 naive NA NA NA NA
#> 19 1.0000000 naive NA NA NA NA
#> 20 1.0000000 naive NA NA NA NA
#> 21 1.0165523 naive NA NA NA NA
#> 22 1.0606602 naive NA NA NA NA
#> 23 1.0312500 naive NA NA NA NA
#> 24 1.1250000 naive NA NA NA NA
#> 25 1.5000000 naive NA NA NA NA
#> 26 3.0000000 naive NA NA NA NA
#> 27 1.4755759 naive NA NA NA NA
#> 28 2.8284271 naive NA NA NA NA
#> 29 1.4545455 naive NA NA NA NA
#> 30 2.6666667 naive NA NA NA NA
#> 31 1.0000000 naive NA NA NA NA
#> 32 1.0000000 naive NA NA NA NA
#> 33 0.9837173 naive NA NA NA NA
#> 34 0.9428090 naive NA NA NA NA
#> 35 0.9696970 naive NA NA NA NA
#> 36 0.8888889 naive NA NA NA NA
#> 37 1.8750000 naive NA NA NA NA
#> 38 2.2500000 naive NA NA NA NA
#> 39 1.7838107 naive NA NA NA NA
#> 40 2.1213203 naive NA NA NA NA
#> 41 1.7142857 naive NA NA NA NA
#> 42 2.0000000 naive NA NA NA NA