apa_seg: Calculate the segregation index of NDiv

Description Usage Arguments Details References Examples

View source: R/apa_randomization.R

Description

The segregation index of NDiv assesses how much NDiv deviates from its random expectation using a randomization approach. Values close to zero indicate a random distribution of the traits that were used to calculate NDiv, values larger than zero indicate a regular distribution (stem-wise mixing) and values smaller than zero indicate a clustered configuration (patch-wise mixing).

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
apa_seg(
  apa_list,
  nsim = 1000,
  save_folder = NULL,
  save_simulations = TRUE,
  overwrite = FALSE,
  buffer_separate = TRUE,
  parallel = TRUE,
  cl = NULL,
  no_cores = 1,
  iseed = 42
)

Arguments

apa_list

A apa_list-object that was created with the [apa_list]-function.

nsim

Integer, how many simulation runs will be done.

save_folder

If specified, intermediate simulation results and processing report will be stored in this folder (defaults to NULL).

save_simulations

If TRUE (default) and if save_folder is specified, individual simulations will be stored (may consume large storage capacities).

overwrite

If FALSE (default), save_folder needs to be empty. If TRUE, all content in save_folder will be deleted before the new simulations start.

buffer_separate

Should tree locations in the buffer and cores zones be randomized separately? Defaults to TRUE.

parallel

If TRUE (default), parallel processing will be used.

cl

If parallel is TRUE, a Parallel Socket Cluster that was created with the [parallel::makeCluster()]-function is specified here. If NULL (default), parallel::makeCluster(no_cores) will be used.

no_cores

The number of cores that will be used for parallel processing (default is 1). If NULL is specified, parallel::detectCores() - 1 will be used to automatically use one core less than available.

iseed

A seed that will be passed to [parallel::clusterSetRNGStream] to make simulations reproducible when parallel processing is used (default is 42).

Details

See Glatthorn (2021) for details.

References

Glatthorn, Jonas (2021). A spatially explicit index for tree species or trait diversity at neighborhood and stand level. Ecological Indicators, 130, 108073. https://doi.org/10.1016/j.ecolind.2021.108073.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
library(APAtree)
data(tree_enrico, package = "APAtree")
data(plot_enrico, package = "APAtree")

tree_enrico$height_class <- tree_enrico$height > 20

# only calculating an apa_list for two plots and with a coarse resolution of 1 m
# to save time.
apa_list_enrico <- 
  apa_list(plot_dat = subset(plot_enrico, id_plot %in% c("5.2", "8.2")), 
           tree_dat = tree_enrico,
           buffer_column = "buffer_geometry",
           core_column = "border_geometry",
           plot_id_column = "id_plot",
           tree_id_column = "id_tree",
           weight_column = "crown_radius_95",
           agg_class_column = c("species", "height_class"),
           res = 10,
           apa_polygon = FALSE)

apa_list_enrico <- 
  apa_ndiv(apa_list_enrico, dis_trait_column = "species")

apa_list_enrico <-
  apa_seg(apa_list_enrico, nsim = 3, parallel = FALSE)

# stand-level segregation index of SpeciesNDiv
apa_list_enrico$plot_dat[, c("id_plot", "seg_species_ndiv")]

JonasGlatthorn/APAtree documentation built on Dec. 18, 2021, 1:41 a.m.