Skip to contents

Compares Shannon/Simpson diversity between samples.

Usage

test_shannon(x, y, ...)

test_simpson(x, y, ...)

# S4 method for class 'numeric,numeric'
test_shannon(x, y, ...)

# S4 method for class 'matrix,missing'
test_shannon(x, adjust = "holm", ...)

# S4 method for class 'data.frame,missing'
test_shannon(x, adjust = "holm", ...)

# S4 method for class 'numeric,numeric'
test_simpson(x, y, adjust = "holm", ...)

# S4 method for class 'matrix,missing'
test_simpson(x, adjust = "holm", ...)

# S4 method for class 'data.frame,missing'
test_simpson(x, adjust = "holm", ...)

Arguments

x, y

A numeric vector, a \(m \times p\) matrix or data.frame of count data (absolute frequencies giving the number of individuals for each category, i.e. a contingency table). A data.frame will be coerced to a numeric matrix via data.matrix().

...

Further arguments to be passed to internal methods.

adjust

A character string specifying the method for adjusting \(p\) values (see stats::p.adjust()).

Value

If x and y are numeric vectors, returns a list containing the following components:

statistic

The value of the t-statistic.

parameter

The degrees of freedom for the t-statistic.

p.value

The p-value for the test.

If x is a matrix or a data.frame, returns a table of adjusted p-values in lower triangular form.

Functions

  • test_shannon(x = matrix, y = missing): Produces two sided pairwise comparisons.

  • test_shannon(x = data.frame, y = missing): Produces two sided pairwise comparisons.

  • test_simpson(x = matrix, y = missing): Produces two sided pairwise comparisons.

  • test_simpson(x = data.frame, y = missing): Produces two sided pairwise comparisons.

References

Magurran, A. E. (1988). Ecological Diversity and its Measurement. Princeton, NJ: Princeton University Press. doi:10.1007/978-94-015-7358-0 .

Author

N. Frerebeau

Examples

## Data from Magurran 1988, p. 145-149
oakwood <- c(35, 26, 25, 21, 16, 11, 6, 5, 3, 3,
             3, 3, 3, 2, 2, 2, 1, 1, 1, 1, 0, 0)
spruce <- c(30, 30, 3, 65, 20, 11, 0, 4, 2, 14,
            0, 3, 9, 0, 0, 5, 0, 0, 0, 0, 1, 1)

test_shannon(oakwood, spruce)
#> $statistic
#> [1] 3.534228
#> 
#> $parameter
#> [1] 358.1946
#> 
#> $p.value
#> [1] 0.0004625638
#> 
test_simpson(oakwood, spruce)
#> $statistic
#> [1] -2.871559
#> 
#> $parameter
#> [1] 324.5595
#> 
#> $p.value
#> [1] 0.004353068
#> 

## Data from Conkey 1980, Kintigh 1989
data("cantabria")

test_shannon(cantabria)
#>                      Altamira Cueto de la Mina El Juyo El Cierro
#> Cueto de la Mina 8.268025e-02               NA      NA        NA
#> El Juyo          3.754291e-05       0.06016855      NA        NA
#> El Cierro        3.526160e-05       0.05708787       1        NA
#> La Paloma        3.255839e-05       0.01313679       1         1
test_simpson(cantabria)
#>                    Altamira Cueto de la Mina El Juyo El Cierro
#> Cueto de la Mina 0.84391773               NA      NA        NA
#> El Juyo          0.05934092        0.6404647      NA        NA
#> El Cierro        0.32909278        1.0000000       1        NA
#> La Paloma        0.37092662        1.0000000       1         1