pval: Permutation test on distances

Description Usage Arguments Value References See Also Examples

View source: R/pval.R

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

1
	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

1
2
3
4
5
6
7
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)

Example output

Loading required package: permute
Loading required package: mclust
Package 'mclust' version 5.3
Type 'citation("mclust")' for citing this R package in publications.

Attaching package: 'Traitspace'

The following object is masked from 'package:permute':

    check

** Warning **: the observed relative abundances/species distributions are calculated from the trait data! 
 This may not be the correct value. Please refer to the documentation for details! 
$Pval
$Pval$EUC.dist
[1] 0.015

$Pval$MAN.dist
[1] 0.015

$Pval$H.dist
[1] 0.015

$Pval$KL.div.D1
[1] 0.015

$Pval$B.dist
[1] 0.015


$mean.dist
$mean.dist$EUC.dist
[1] 0.2871345

$mean.dist$MAN.dist
[1] 0.4394254

$mean.dist$H.dist
[1] 0.2081156

$mean.dist$KL.div.D1
[1] 0.2710183

$mean.dist$B.dist
[1] 0.04565618


$Pval_site
$Pval_site$EUC.dist
[1] 0.187 0.181 0.181 0.186 0.202

$Pval_site$MAN.dist
[1] 0.187 0.181 0.181 0.186 0.202

$Pval_site$H.dist
[1] 0.187 0.181 0.181 0.186 0.202

$Pval_site$KL.div.D1
[1] 0.187 0.181 0.181 0.186 0.202

$Pval_site$B.dist
[1] 0.187 0.181 0.181 0.186 0.202


$dist_site
$dist_site$EUC.dist
       -3      -1.5         0       1.5         3 
0.2511360 0.3871558 0.2423266 0.3363224 0.2187316 

$dist_site$MAN.dist
       -3      -1.5         0       1.5         3 
0.3551600 0.6136381 0.4126487 0.5041800 0.3115000 

$dist_site$H.dist
       -3      -1.5         0       1.5         3 
0.1873688 0.2761394 0.2291661 0.2207461 0.1271577 

$dist_site$KL.div.D1
        -3       -1.5          0        1.5          3 
0.16874098 0.35714237 0.47227004 0.25776798 0.09917022 

$dist_site$B.dist
        -3       -1.5          0        1.5          3 
0.03508827 0.07793313 0.05131214 0.04864502 0.01530235 

Traitspace documentation built on May 2, 2019, 4:10 a.m.

Related to pval in Traitspace...