raref_test: Rarefaction testing with rarefactions within permutations

Description Usage Arguments Value Examples

View source: R/Rarefaction_funs.R

Description

Rarefaction testing with rarefactions within permutations

Usage

1
2
3
4
raref_test(comm, ttt, n_raref = 50, nperm = 200, method = "jaccard",
  binary = TRUE, ptype = c("raref_perm_medianp", "raref_perm_meanF",
  "raref_perm_meanp"), return.all = FALSE, dummy_raref = FALSE,
  seed = NULL)

Arguments

comm

community matrix (patches=rows, species=columns)

ttt

treatment vector (treatment id of each patch)

n_raref

number of rarefactions

nperm

number of permutations

method

beta diversity metric (passed to vegan::betadisper)

binary

reduce data to presence/absence? (passed to vegan::betadisper)

ptype

p-value calculations: "raref_perm_meanF", calculate mean F-statistics within permutations; "raref_perm_meanp", calculate mean p-value across permutations; "raref_perm_medianp" (default), calculate median p-value across permutations.

return.all

(logical) return all information rather than summarized test statistics?

dummy_raref

(logical) [TESTING ONLY] fake rarefaction? (i.e., don't actually do any rarefaction)

seed

random-number seed

Value

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

method

a string giving the method and number of rarefactions used

estimate

the mean beta diversity (measured as median distance from centroid) across all sites and rarefactions

conf.int

the confidence interval of the mean beta diversities across rarefactions

statistic

the median F-statistic across permutations

p.value

the p-value corresponding to the statistic

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
set.seed(101)
sx <- simComm(n.site=20,p.mix=0.5,n.indiv.site=c(10,20),totsp=c(20,40))
plot(sx)
raref_test(sx[,-1],sx[,1])
tmpf <- function(...) {
   sx <- simComm(...)
   tt <- try(raref_test(sx[,-1],sx[,1])$p.value)
   if (is(tt,"try-error")) return(NA) else return(tt)
}
## Not run: 
## compute power for this case
set.seed(101)
system.time(pvec <- replicate(100,tmpf(n.site=20,p.mix=0.5,
                       n.indiv.site=c(10,20),totsp=c(20,40))))
## ~ 10 minutes
hist(pvec,breaks=20,xlim=c(0,1),col="gray")
mean(pvec<0.05)  ## 0; conservative (but very small sample!)

## End(Not run)

bbolker/betararef documentation built on Sept. 17, 2021, 8:49 a.m.