Learn R Programming

Traitspace (version 1.1)

pval: Permutation test on distances

Description

First calls the function distTraitspace to calculate the distances between the predicted and true/observed relative abundances (by default) or species distributions if byrow = FALSE. Then runs permutation tests to test if these distances are statistically significant and provides p-values.

Usage

pval(result, obs = NULL, byrow = TRUE, permutations = 999)

Arguments

result
the output from the traitspace function (class Traitspace)
obs
The observed matrix - where, each row corresponds to a site and each column to a species - the order of sites and species should match with the order in which they appear in the predicted matrix. By default, NULL, will generate the observed matrix using the supplied trait data using the trueP function. See the trueP function for details.
byrow
By default, TRUE, will compare the relative abundances. If FALSE, will compare the species distribution.
permutations
Number of permutations, by default 999.

Value

A list of distances calculated using the following measures: Euclidean, Manhatten, Hellinger, Kullback-Leibler and Bhattacharya. It calculates both the average distance (averages across all sites or species) as well as individual distances. Also provides p-values corresponding to each of these distances.

References

Basu, A., Shioya, H., & Park, C. (2011). Statistical inference: the minimum distance approach. CRC Press.

Phipson, B., & Smyth, G. K. (2010). Permutation p-values should never be zero: calculating exact P-values when permutations are randomly drawn. Statistical applications in genetics and molecular biology, 9(1).

See Also

distTraitspace, Traitspace, TraitspaceMod

Examples

Run this code
data(spdata)
species<-spdata$species  #species column
trt<-cbind(spdata$t1,spdata$t2) #two traits
env<-spdata$env     #one env gradient
site<-spdata$site   #site information
result1<-Traitspace(species, trt, env, site)
pval(result1)

Run the code above in your browser using DataLab