Calculates the Shannon entropy of a probability vector.
1 2 3 4 5 6 7 8 9 10 11 12 13
Shannon(NorP, ...) bcShannon(Ns, Correction = "Best", CheckArguments = TRUE) ## S3 method for class 'ProbaVector' Shannon(NorP, ..., CheckArguments = TRUE, Ps = NULL) ## S3 method for class 'AbdVector' Shannon(NorP, Correction = "Best", ..., CheckArguments = TRUE, Ns = NULL) ## S3 method for class 'integer' Shannon(NorP, Correction = "Best", ..., CheckArguments = TRUE, Ns = NULL) ## S3 method for class 'numeric' Shannon(NorP, Correction = "Best", ..., CheckArguments = TRUE, Ps = NULL, Ns = NULL)
A probability vector, summing to 1.
A numeric vector containing species abundances.
A numeric vector, an integer vector, an abundance vector (
A string containing one of the possible corrections:
Additional arguments. Unused.
Bias correction requires the number of individuals to estimate sample
bcShannon and choose the
Correction techniques are from Miller (1955), Chao and Shen (2003), Grassberger (1988), Grassberger (2003), Schurmann (2003), Holste et al. (1998), Bonachela et al. (2008), Zhang (2012), Chao, Wang and Jost (2013). More estimators can be found in the
MetaCommunity mutual information, Chao, Wang and Jost (2013) calculate reduced-bias Shannon beta entropy (see the last example below) with better results than the Chao and Shen estimator, but community weights cannot be arbitrary: they must be proportional to the number of individuals.
The functions are designed to be used as simply as possible.
Shannon is a generic method. If its first argument is an abundance vector, an integer vector or a numeric vector which does not sum to 1, the bias corrected function
bcShannon is called. Explicit calls to
bcShannon (with bias correction) or to
Shannon.ProbaVector (without correction) are possible to avoid ambiguity. The
.numeric methods accept
Ns arguments instead of
NorP for backward compatibility.
A named number equal to the calculated entropy. The name is that of the bias correction used.
Eric Marcon <[email protected]>
Bonachela, J. A., Hinrichsen, H. and Munoz, M. A. (2008). Entropy estimates of small data sets. Journal of Physics A: Mathematical and Theoretical 41(202001): 1-9.
Chao, A. and Shen, T. J. (2003). Nonparametric estimation of Shannon's index of diversity when there are unseen species in sample. Environmental and Ecological Statistics 10(4): 429-443.
Chao, A., Wang, Y. T. and Jost, L. (2013). Entropy and the species accumulation curve: a novel entropy estimator via discovery rates of new species. Methods in Ecology and Evolution 4(11):1091-1100.
Grassberger, P. (1988). Finite sample corrections to entropy and dimension estimates. Physics Letters A 128(6-7): 369-373.
Grassberger, P. (2003). Entropy Estimates from Insufficient Samplings. ArXiv Physics e-prints 0307138.
Holste, D., Grosse, I. and Herzel, H. (1998). Bayes' estimators of generalized entropies. Journal of Physics A: Mathematical and General 31(11): 2551-2566.
Miller, G. (1955) Note on the bias of information estimates. In: Quastler, H., editor. Information Theory in Psychology: Problems and Methods: 95-100.
Shannon, C. E. (1948). A Mathematical Theory of Communication. The Bell System Technical Journal 27: 379-423, 623-656.
Schurmann, T. (2004). Bias analysis in entropy estimation. Journal of Physics A: Mathematical and Theoretical 37(27): L295-L301.
Tsallis, C. (1988). Possible generalization of Boltzmann-Gibbs statistics. Journal of Statistical Physics 52(1): 479-487.
Zhang, Z. (2012). Entropy Estimation in Turing's Perspective. Neural Computation 24(5): 1368-1389.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
# Load Paracou data (number of trees per species in two 1-ha plot of a tropical forest) data(Paracou618) # Ns is the total number of trees per species Ns <- as.AbdVector(Paracou618.MC$Ns) # Species probabilities Ps <- as.ProbaVector(Paracou618.MC$Ns) # Whittaker plot plot(Ns) # Calculate Shannon entropy Shannon(Ps) # Calculate the best estimator of Shannon entropy Shannon(Ns) # Use metacommunity data to calculate reduced-bias Shannon beta as mutual information (bcShannon(Paracou618.MC$Ns) + bcShannon(colSums(Paracou618.MC$Nsi)) - bcShannon(Paracou618.MC$Nsi))
None 4.736023 ChaoWangJost 4.892159 ChaoWangJost 0.3701823
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.