generic.metrics: Calculate any metric(s) (and compare with null distributions)

Description Usage Arguments Details Value Note Author(s) References Examples

View source: R/metric.null.R

Description

Allow the calculation of any metric within pez.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
generic.null(
  data,
  metrics,
  null.model = c("taxa.labels", "richness", "frequency", "sample.pool",
    "phylogeny.pool", "independentswap", "trialswap", "trait.asm"),
  permute = 1000,
  comp.fun = .ses,
  ...
)

.ses(observed, null)

.metric.null(
  data,
  metrics,
  null.model = c("taxa.labels", "richness", "frequency", "sample.pool",
    "phylogeny.pool", "independentswap", "trialswap", "trait.asm"),
  permute = 1000,
  trait = -1,
  ...
)

generic.metrics(data, metrics, ...)

Arguments

data

data comparative.comm object

metrics

vector of functions to be calculated on data; see pez.metrics for a list of them.

null.model

one of "taxa.labels", "richness", "frequency", "sample.pool", "phylogeny.pool", "independentswap", or "independentswap". These correspond to the null models available in picante

permute

number of null permutations to perform (default 1000)

comp.fun

comparison function to compare observed values with null values. Default is .ses; this is a Standard Effect Size (obs - mean)/SEmean. You may supply your own function; it should take the observed site-metric matrix as its first argument, and a site-metric-permutation array as its second. See the internals of generic.null for an example of its use.

...

additional arguments (e.g, dist, abundance.weighted) to be passed to any metric functions (see generic.metrics for possible arguments)

observed

observed metric values in site-metric matrix (e.g., from generic.metrics)

null

null distributions (e.g., from .metric.null) in a site-metric-permutation array

trait

if using trait.asm null.model, which trait to use (as in trait.asm)

Details

generic.null Calculate metrics and compare with null distributions. Very light wrapper around the utility functions generic.null and generic.metrics (which is, itself, a very simple function!).

Value

generic.null Output from comp.fun, by default an array (site-metric-type), where type is the observed value, the mean of the null permutations, the Standard Error of that mean, the Standard Effect Size of the metric (obs-null.mean)/SE, and then the rank of the observed value in the permutations. The rank can be considered a bootstrapped p-value of significance, but remember that this is a rank: at the 95 would be significant.

.ses Vector of standard effect sizes

.metric.null site-metric-permutation array

generic.metrics site-metric matrix

Note

comp.fun can be anything; much ink has been written about the use of standard effect sizes in eco-phylogenetic analyses (e.g., Kembel 2009). That this function makes it easy for you to compute Standard Effect Sizes does not necessarily mean that you should (see Pearse et al. 2013).

Calculating null permutations on a dispersion metric makes little sense, since (by definition; see Pearse et al. 2014) a dispersion metric require the use of a null distribution to be calculated. There is nothing to stop you doing so, however! The code makes no attempt to stop you calculating null dissimilarity metrics, but I am not certain that doing so is a good idea using this code as I don't know what to do with such null models!

The pez.shape, pez.evenness, pez.dispersion, and pez.dissimilarity wrapper functions go to some trouble to stop you calculating metrics using inappropriate data (see their notes). These functions give you access to the underlying code within pez; there is nothing I can do to stop you calculating a metric that, in my opinion, doesn't make any sense. You have been warned :D

Author(s)

Will Pearse

References

Kembel S.W. (2009) Disentangling niche and neutral influences on community assembly: assessing the performance of community phylogenetic structure tests. Ecology letters, 12(9), 949-960.

Pearse W.D., Jones F.A. & Purvis A. (2013) Barro Colorado Island's phylogenetic assemblage structure across fine spatial scales and among clades of different ages. Ecology, 94(12), 2861-2872.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
#Setup data
data(laja)
data <- comparative.comm(invert.tree, river.sites, invert.traits)
#Calculate some metrics
generic.metrics(data, c(.mpd, .pse))
#Compare with a trait-based null model (trait.asm)
generic.null(data, c(.mpd, .pse), "trait.asm", permute=10, trait="fish.pref")
#...be patient when running large (e.g., 1000) sets of null simulations
#You can also do this in pieces, giving even more flexibility
observed <- generic.metrics(data, c(.mpd, .pse))
#null <- .metric.null(data, c(.mpd, .pse))
#ses <- .ses(observed, null)
#...this is how everything works within generic.null
#...and, as with everything in pez, all internal functions start with a "."

Example output

Loading required package: ape
           [,1]       [,2]
 [1,]  985.2757 0.27240401
 [2,] 1161.5548 0.08472808
 [3,]  924.7704 0.47064267
 [4,]  986.4490 0.16451715
 [5,]  976.4242 0.41934991
 [6,] 1117.2675 0.66797969
 [7,]  950.1255 0.35540956
 [8,]  813.7778 0.41866080
 [9,]  924.5633 0.02698192
[10,]  894.0298 0.32822173
[11,]  978.9238 0.18456052
, , observed

           [,1]       [,2]
 [1,]  985.2757 0.27240401
 [2,] 1161.5548 0.08472808
 [3,]  924.7704 0.47064267
 [4,]  986.4490 0.16451715
 [5,]  976.4242 0.41934991
 [6,] 1117.2675 0.66797969
 [7,]  950.1255 0.35540956
 [8,]  813.7778 0.41866080
 [9,]  924.5633 0.02698192
[10,]  894.0298 0.32822173
[11,]  978.9238 0.18456052

, , null.mean

          [,1]     [,2]
 [1,] 318.3228 344.1940
 [2,] 344.1940 318.3228
 [3,] 318.3228 344.1940
 [4,] 344.1940 318.3228
 [5,] 318.3228 344.1940
 [6,] 344.1940 318.3228
 [7,] 318.3228 344.1940
 [8,] 344.1940 318.3228
 [9,] 318.3228 344.1940
[10,] 344.1940 318.3228
[11,] 318.3228 344.1940

, , SE

          [,1]     [,2]
 [1,] 108.0162 115.1080
 [2,] 115.1080 108.0162
 [3,] 108.0162 115.1080
 [4,] 115.1080 108.0162
 [5,] 108.0162 115.1080
 [6,] 115.1080 108.0162
 [7,] 108.0162 115.1080
 [8,] 115.1080 108.0162
 [9,] 108.0162 115.1080
[10,] 115.1080 108.0162
[11,] 108.0162 115.1080

, , SES

          [,1]      [,2]
 [1,] 6.174564 -2.987818
 [2,] 7.100819 -2.946207
 [3,] 5.614414 -2.986096
 [4,] 5.579588 -2.945469
 [5,] 6.092618 -2.986542
 [6,] 6.716073 -2.940808
 [7,] 5.849148 -2.987097
 [8,] 4.079507 -2.943116
 [9,] 5.612497 -2.989950
[10,] 4.776697 -2.943953
[11,] 6.115759 -2.988581

, , rank

      [,1] [,2]
 [1,]  1.1  0.1
 [2,]  1.1  0.1
 [3,]  1.1  0.2
 [4,]  1.1  0.1
 [5,]  1.1  0.2
 [6,]  1.1  0.6
 [7,]  1.1  0.1
 [8,]  1.1  0.4
 [9,]  1.1  0.1
[10,]  1.1  0.1
[11,]  1.1  0.1

pez documentation built on June 17, 2021, 5:11 p.m.