 Dataplot Vol 2 Vol 1

# SHANNON DIVERSITY INDEX

Name:
SHANNON DIVERSITY INDEX (LET)
Type:
Let Subcommand
Purpose:
Compute the Shannon diversity index.
Description:
Diversity indices are statistics used to summarize the diversity of a population in which each member belongs to a unique group. For example, in ecology the groups are typically species. In ecology, species richness refers to number of species and species eveness refers to homogeneity of the species. That is, the more equal the proportions for each of the groups, the more homogeneous, or even, they are. Different fields of application may use different terminology for these concepts.

Given a vector of frequencies (counts), fi the Shannon diversity index is computed as

$$H = \frac{n \log(n) - \sum_{i=1}^{k}{f_{i} \log(f_{i})}} {n}$$

with k and n denoting the number of groups and the total count, respectively. If fi = 0, then the fi log(fi) term is set to 0.

The maximum value of the index is LOG(k). This value occurs when each group has the same frequency (i.e., maximum eveness).

The Shannon equitability index is simply the Shannon diversity index divided by the maximum diversity

$$E_{H} = \frac{H}{\log(k)}$$

This normalizes the Shannon diversity index to a value between 0 and 1. Note that lower values indicate more diversity while higher values indicate less diversity. Specifically, an index value of 1 means that all groups have the same frequency. Some analysts use 1 - E(H) so that higher values indicate higher diversity. Some analysts also use 1/E(H).

In some cases, you may have proportions rather than counts. In this case, the formula for the Shannon diversity index is

$$H = - \sum_{i=1}^{k}{p_{i} \log(p_{i})}$$

with pi denoting the proportion in group k. As above, the Shannon equitability index is computed as

$$E_{H} = \frac{H}{\log(k)}$$

You may also have raw data. That is, each row of the response variable identifies which group that row belongs to. In this case, Dataplot will generate the frequency table and use the formulas above to compute the index.

Syntax 1:
LET <par> = SHANNON <DIVERSITY/EQUITABILITY> INDEX <y>
<SUBSET/EXCEPT/FOR qualification>
where <y> is the response variable;
<DIVERSITY/EQUITABILITY> specifies whether the diversity or equitability index is computed;
<par> is a parameter where the Shannon diversity index is saved;
and where the <SUBSET/EXCEPT/FOR qualification> is optional.

This syntax is used when the response variable is either a set of proportions or a set of counts. Dataplot sums the values in the response variable. If the sum equals 1, then it assumes the response variable contains proportions. Otherwise, it assumes the response variable contains frequencies. In either case, if negative values are encountered an error is reported.

Syntax 2:
LET <par> = RAW SHANNON <DIVERSITY/EQUITABILITY> INDEX <y>
<SUBSET/EXCEPT/FOR qualification>
where <y> is the response variable;
<DIVERSITY/EQUITABILITY> specifies whether the diversity or equitability index is computed;
<par> is a parameter where the Shannon diversity index is saved;
and where the <SUBSET/EXCEPT/FOR qualification> is optional.

This syntax is used when the response variable is a group-id variable. The group frequencies will be computed automatically.

Examples:
LET SDI = SHANNON DIVERSITY P
LET SEI = SHANNON EQUITABILITY P
Note:
The Shannon diversity/equitability is used in a wide variety of fields. It may be referred to by a different name or have a slightly different formulation in various fields.
Note:
Dataplot statistics can be used in a number of commands. For details, enter

The SHANNON DIVERSITY INDEX command is not typically used in the context of these other commands.

Default:
None
Synonyms:
SHANNON EVENESS INDEX is a synonym for SHANNON EQUIABILIY INDEX
Related Commands:
 SIMPSON DIVERSITY INDEX = Compute the Simpson diversity index.
References:
Weaver, W.; C.E. Shannon (1949), "The Mathematical Theory of Communication," Urbana, Illinois: University of Illinois.

Shannon, C.E. (July and October 1948), "A mathematical theory of communication," Bell System Technical Journal, 27: 379–423 and 623–656.

Brani Vidakovic (2011), "Statistics for Bioengineering Sciences: With MATLAB and WinBUGS Support," Springer, p. 23.

Applications:
Data Management
Implementation Date:
2011/12
Program:

let p = data 0.25 0.15 0.40 0.20
let nk = size p
.
let a = shannon diversity index p
let b = shannon equitability index p

The following output is generated
THE COMPUTED VALUE OF THE CONSTANT A             =    1.319545

THE COMPUTED VALUE OF THE CONSTANT B             =   0.9518508

.
.  Following example from page 23 of:
.
.     Brani Vidakovic (2011), "Statistics for Bioengineering
.     Sciences: With MATLAB and WinBUGS Support", Springer.
.
115  1
108  1
25  1
6  1
28  1
25  1
6  1
1  1
220  2
134  2
183  2
39  2
12  2
6  2
6  2
12  2
83  3
104  3
16  3
8  3
14  3
18  3
2  3
1  3
99  4
94  4
21  4
8  4
18  4
18  4
5  4
2  4
end of data
.
set write decimals 4
tabulate shannon diversity index y x
tabulate shannon equitability index y x

The following output is generated
            Cross Tabulate SHANNON DIVERSITY INDEX

(Response Variables: Y        )
---------------------------------------------
X          |   SHANNON DIVERSI
---------------------------------------------
1.0000   |            1.5230
2.0000   |            1.4816
3.0000   |            1.4356
4.0000   |            1.5191

Cross Tabulate SHANNON EQUITABILITY INDEX

(Response Variables: Y        )
---------------------------------------------
X          |   SHANNON EQUITAB
---------------------------------------------
1.0000   |            0.7324
2.0000   |            0.7125
3.0000   |            0.6904
4.0000   |            0.7305

.
let yn = cross tabulate sum y x
let pn = y/yn
tabulate shannon diversity index pn x
tabulate shannon equitability index pn x

The following output is generated
            Cross Tabulate SHANNON DIVERSITY INDEX

(Response Variables: PN       )
---------------------------------------------
X          |   SHANNON DIVERSI
---------------------------------------------
1.0000   |            1.5230
2.0000   |            1.4816
3.0000   |            1.4356
4.0000   |            1.5191

Cross Tabulate SHANNON EQUITABILITY INDEX

(Response Variables: PN       )
---------------------------------------------
X          |   SHANNON EQUITAB
---------------------------------------------
1.0000   |            0.7324
2.0000   |            0.7125
3.0000   |            0.6904
4.0000   |            0.7305


NIST is an agency of the U.S. Commerce Department.

Date created: 12/08/2011
Last updated: 10/07/2016