| ps_rand | R Documentation |
This function compares phylodiversity metrics calculated in ps_diversity to their null distributions computed by randomizing the community matrix or shuffling the tips of the phylogeny, indicating statistical significance under the assumptions of the null model. Various null model algorithms are available for binary, probability, and count data.
ps_rand(
ps,
metric = c("PD", "PE", "RPE", "CE"),
fun = "tip_shuffle",
method = NULL,
n_iter = 1000,
n_rand = 100,
summary = "quantile",
spatial = TRUE,
n_cores = 1,
progress = interactive(),
wt_row = NULL,
wt_col = NULL,
...
)
ps |
|
metric |
Character vector giving one or more diversity metrics to calculate; see ps_diversity
for options. Can also specify |
fun |
Null model function to use. Must be either "tip_shuffle", "nullmodel", "nullcat", "quantize", or an actual function:
|
method |
Method used by the selected function.
|
n_iter |
Integer giving the number of swap iterations per randomized matrix. Controls
how thoroughly each null matrix is mixed before sampling. Default is |
n_rand |
Integer giving the number of random communities to generate. |
summary |
Character indicating which summary statistic to return. If |
spatial |
Logical: should the function return a spatial object (TRUE, default) or a matrix (FALSE). |
n_cores |
Integer giving the number of compute cores to use for parallel processing. |
progress |
Logical: should a progress bar be displayed? |
wt_row, wt_col |
Optional square numeric weight matrices controlling which pairs of
rows (sites) or columns (species) are likely to exchange values during randomization.
Only used with |
... |
Additional arguments passed to the selected function: quantize,
nullcat, simulate.nullmodel, or a custom function.
Note that the |
If ps has site weights (see the site_weight argument of phylospatial()), they are used in calculating
range sizes for endemism metrics, in both the observed and the randomized communities. Note, however, that null model
algorithms that randomize the community matrix preserve taxon totals across sites, not weighted range sizes. With unequal
site weights, a randomized taxon can therefore have a larger or smaller range size than the observed taxon, depending on
which sites it is moved into, so null distributions of endemism metrics do not hold range sizes fixed. The default
"tip_shuffle" method is not affected, since it moves intact terminal ranges among taxa.
A matrix with a row for every row of x, a column for every metric specified in metric, and
values for the summary statistic. Or if spatial = TRUE, a sf or SpatRaster object containing these data.
ps_diversity(), ps_geodist()
# simulate a `phylospatial` data set and run randomization with default settings
ps <- ps_simulate(data_type = "prob")
rand <- ps_rand(ps)
# using the `quantize` function with the `curvecat` algorithm
if(requireNamespace("nullcat")){
rand <- ps_rand(ps,
fun = "quantize", method = "curvecat",
transform = sqrt, n_strata = 4, fixed = "cell")
}
# binary data with nullcat's curvecat algorithm
ps2 <- ps_simulate(data_type = "binary")
if(requireNamespace("nullcat")){
rand <- ps_rand(ps2, fun = "nullcat", method = "curvecat", n_iter = 1000)
}
# spatially constrained randomization using geographic distance weights
if(requireNamespace("nullcat")){
geo <- as.matrix(ps_geodist(ps2))
W <- exp(-geo / median(geo))
rand <- ps_rand(ps2, fun = "nullcat", method = "curvecat",
n_iter = 1000, wt_row = W)
}
# using binary data, with a vegan `nullmodel` algorithm
rand <- ps_rand(ps2, "PD", "nullmodel", "r2")
# using abundance data
ps3 <- ps_simulate(data_type = "abund")
rand <- ps_rand(ps3, metric = c("ShPD", "SiPD"),
fun = "nullmodel", method = "abuswap_c")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.