Title: Community Ecology Tests
Version: 0.0.1
Description: Functions and data sets to perform and demonstrate community ecology statistical tests, including Hutcheson's t-test (Hutcheson (1970) <doi:10.1016/0022-5193(70)90124-4>, Zar (2010) ISBN:9780321656865).
Imports: stats
License: MIT + file LICENSE
Encoding: UTF-8
BugReports: https://github.com/hugosal/ecolTest/issues
URL: https://github.com/hugosal/ecolTest
LazyData: true
RoxygenNote: 7.1.1
Depends: R (≥ 2.10)
NeedsCompilation: no
Packaged: 2021-02-11 18:29:15 UTC; hugo
Author: Hugo Salinas [aut, cre], David Ramirez-Delgado [aut]
Maintainer: Hugo Salinas <hugosal@comunidad.unam.mx>
Repository: CRAN
Date/Publication: 2021-02-15 11:00:02 UTC

Hutcheson's t-test for two diversity indices.

Description

This function performs Hutcheson's t-test for significance of the difference between the diversity indices of two communities.

Usage

Hutcheson_t_test(
  x,
  y,
  shannon.base = exp(1),
  alternative = "two.sided",
  difference = 0
)

Arguments

x, y

Numeric vectors of abundance of species for community sample x and community sample y.

shannon.base

A numeric value indicating the logarithm base for the Shannon indices. Defaults to exp(1).

alternative

A character indicating the alternative hypothesis. Can be "two.sided"(default), "less", "greater", or "auto".

difference

A numeric value indicating the hypothesized difference between the diversity indexes. Defaults to 0.

Details

This function performs Hutcheson's t-test for comparing two sample's Shannon diversity indices. This test is based on Shannon diversity indices computed using a logarithm base specified by the user. One-sided and two-sided tests are available.

Value

A list of class "htest" containing the following components:

Note

Missing values will be replaced with zero values.

Author(s)

David Ramirez Delgado linfocitoth1@gmail.com.

Hugo Salinas hugosal@comunidad.unam.mx.

References

Zar, Jerrold H. 2010. Biostatistical Analysis. 5th ed. Pearson. pp. 174-176.

Hutcheson, Kermit. 1970. A Test for Comparing Diversities Based on the Shannon Formula. Journal of Theoretical Biology 29: 151-54.

See Also

See t.test in stats package for t-test.

Examples

data("polychaeta_abundance")
# two-sided test
Hutcheson_t_test(x=polychaeta_abundance$Sample.1,
                 y=polychaeta_abundance$Sample.2,
                 shannon.base = 10)
# one-sided test
Hutcheson_t_test(x=polychaeta_abundance$Sample.1,
                 y=polychaeta_abundance$Sample.2,
                 shannon.base = 10,
                 alternative = "greater")

Pseudo-random community generator

Description

This function generates a random community sample dataset that has a user-specified Shannon diversity index, species number, and total abundance.

Usage

generate_random_community(
  H_index,
  shannon.base = exp(1),
  sp_num,
  ntotal,
  tol = 1e-04,
  maxiter = 100,
  silent = FALSE
)

Arguments

H_index

The value of the generated communty Shannon diversity index H'.

shannon.base

A numeric value indicating the logarithm base for the Shanon indices. Defaults to e.

sp_num

Numeric. The number of species in the generated community sample.

ntotal

Numeric. The total number of individuals in the generated community sample.

tol

Numeric. The tolerance of the diffrence of the diversity index of the generated community relative abundance and the H_index argument. Defaults to 0.0001.

maxiter

Numeric. The maximum number of iterations to be performed. Defaults to 100.

silent

Logical. Indicates if convergence success or failure messages are omitted. Defaults to FALSE.

Details

This function generates random community sample data: a numeric vector whose elements represent a sample. The generated sample data is composed of a number of species with a total number of individuals set by the user, such that the community has a Shannon diversity index approximately equal to a user-specified argument.

Value

A list containing the following components:

Author(s)

David Ramirez Delgado linfocitoth1@gmail.com

Hugo Salinas hugosal@comunidad.unam.mx

Examples

# Generate a community with diversity index 2, composed of 20 species
# and 200 total individuals sampled
set.seed(26)
result <- generate_random_community(H_index = 2.7, sp_num = 20, ntotal = 200,
 maxiter = 300)
random_community <- result$community

#Compute H index
total <- sum(random_community)
-sum(random_community/total*log(random_community/total))

#Default maxiter argument will not converge
set.seed(26)
generate_random_community(H_index = 2.7, sp_num = 20, ntotal = 200)

Multiple Hutcheson t-tests comparisons between communities.

Description

This function computes the p-values of the Hutcheson t-test to test the significance of the difference between more than two communities Shannon diversity indexes, in a pairwise way.

Usage

multiple_Hutcheson_t_test(x, shannon.base = exp(1))

Arguments

x

Numeric dataframe or matrix of abundance of species per community sample. Columns must correspond to the samples and rows to species.

shannon.base

Numeric value indicating the logarithm base for computing the Shannon indexes. Defaults to exp(1).

Details

This function performs Hutcheson's t-tests for comparing multiple diversity indexes pairwise. This test is based on the Shannon diversity index computed using a logarithm base specified by the user. The alternative hypothesis is one-sided, chosen automatically according to the sign of the difference between each pair of communities tested. The resulting p-values of the test are returned in a matrix. To see full details of the results of the test comparing two communities it is better to use Hutcheson_t_test().

Value

A matrix whose entries are the p-values from the test result rounded to five digits. Self-comparison elements (matrix diagonal) are flagged with NA. The names of the rows and columns are the names of the communities with their Shannon diversity index.

Note

Missing values will be replaced with zero.

Author(s)

David Ramirez Delgado linfocitoth1@gmail.com.

Hugo Salinas hugosal@comunidad.unam.mx.

See Also

See Hutcheson_t_test for Hutcheson's t-test details.

Examples

data("polychaeta_abundance")
multiple_Hutcheson_t_test(x = polychaeta_abundance,
                           shannon.base = 10)

Polychaeta abundance recorded in six samples.

Description

A dataset containing the abundance of 38 species of Polychaeta collected in 2013 from six samples from different locations in Bahía de los Ángeles, Ensenada, Baja California, México, by Victoria María Díaz Castañeda, PhD. (Senior Scientist; Laboratorio de Ecología del bentos marino, Departamentoe de Ecología Marina, CICESE).

Usage

polychaeta_abundance

Format

A data frame with 39 rows and 6 variables. Rownames are the name of the species, the columns correspond to number of sample:

Sample.1

The abundance of each species in the sample 1

Sample.2

The abundance of each species in the sample 2

Sample.3

The abundance of each species in the sample 3

Sample.4

The abundance of each species in the sample 4

Sample.5

The abundance of each species in the sample 5

Sample.6

The abundance of each species in the sample 6