Compares the richness and occurrence incidence across species between actual and randomized species distributions
Usage
algorithm_metrics(
x,
spat_alg = NULL,
spat_alg_args = NULL,
aleats = 10,
filename = "",
force_wr_aleat_file = FALSE,
...
)
Arguments
- x
SpatRaster. A SpatRaster containing presence-absence data (0 or 1) for a set of species.
- spat_alg
A function with the algorithm implementing the desired randomization method. It must work with SpatRaster objects. See examples. Example of functions that work are:
bootspat_naive
,bootspat_str
,bootspat_ff
.- spat_alg_args
List of arguments passed to the randomization method chosen in 'spat_alg'. See
bootspat_naive
,bootspat_str
,bootspat_ff
- aleats
positive integer. A positive integer indicating how many times the calculation should be repeated.
- filename
character. Output filename
- force_wr_aleat_file
logical. Force writing bootstrapped rasters, even if files fit in memory. Mostly used for internal test units.
- ...
additional arguments passed to 'terra::app()' function.
Value
a list with two components:
spp_metrics: a matrix with metrics comparing actual and randomized frequency of species occurrence. Metrics are average, sd, min, and max frequency across randomizations, sp_reldiff (average difference relative to species frequency), global_reldiff (average difference relative to the number of available cells), upper and lower confidence intervals for sp_reldiff and global_reldiff.
spat_rich_diff: a SpatRaster with summary statistics about differences between actual and bootstrapped site (cell) richness
Examples
library(SESraster)
library(terra)
r <- load_ext_data()
algorithm_metrics(r, spat_alg = "bootspat_naive", spat_alg_args=list(random="species"), aleats = 3)
#> $spp_metrics
#> actual rand_avg rand_sd rand_min rand_max sp_reldiff global_reldiff
#> sp1 1 1 0 1 1 0 0
#> sp2 14 14 0 14 14 0 0
#> sp3 9 9 0 9 9 0 0
#> sp4 12 12 0 12 12 0 0
#> sp5 12 12 0 12 12 0 0
#> sp6 10 10 0 10 10 0 0
#> sp7 23 23 0 23 23 0 0
#> sp_reldiff_l sp_reldiff_u global_reldiff_l global_reldiff_u
#> sp1 0 0 0 0
#> sp2 0 0 0 0
#> sp3 0 0 0 0
#> sp4 0 0 0 0
#> sp5 0 0 0 0
#> sp6 0 0 0 0
#> sp7 0 0 0 0
#>
#> $spat_rich_diff
#> class : SpatRaster
#> dimensions : 5, 5, 4 (nrow, ncol, nlyr)
#> resolution : 72, 36 (x, y)
#> extent : -180, 180, -90, 90 (xmin, xmax, ymin, ymax)
#> coord. ref. : lon/lat WGS 84 (EPSG:4326)
#> source(s) : memory
#> names : mean_diff, sd_diff, min_diff, max_diff
#> min values : -2.333333, 0.000000, -3, -2
#> max values : 3.000000, 1.732051, 2, 4
#>
algorithm_metrics(r, spat_alg = "bootspat_naive", spat_alg_args=list(random="site"), aleats = 3)
#> $spp_metrics
#> actual rand_avg rand_sd rand_min rand_max sp_reldiff global_reldiff
#> sp1 1 11.00000 2.6457513 9 14 10.00000000 0.41666667
#> sp2 14 13.33333 2.0816660 11 15 -0.04761905 -0.02777778
#> sp3 9 10.33333 1.5275252 9 12 0.14814815 0.05555556
#> sp4 12 11.33333 3.2145503 9 15 -0.05555556 -0.02777778
#> sp5 12 11.66667 2.3094011 9 13 -0.02777778 -0.01388889
#> sp6 10 11.33333 0.5773503 11 12 0.13333333 0.05555556
#> sp7 23 12.00000 4.5825757 7 16 -0.47826087 -0.45833333
#> sp_reldiff_l sp_reldiff_u global_reldiff_l global_reldiff_u
#> sp1 7.35424869 12.6457513 0.306427029 0.52690630
#> sp2 -0.19630948 0.1010714 -0.114513861 0.05895831
#> sp3 -0.02157688 0.3178732 -0.008091329 0.11920244
#> sp4 -0.32343474 0.2123236 -0.161717372 0.10616182
#> sp5 -0.22022787 0.1646723 -0.110113934 0.08233616
#> sp6 0.07559831 0.1910684 0.031499294 0.07961182
#> sp7 -0.67750329 -0.2790184 -0.649273987 -0.26739268
#>
#> $spat_rich_diff
#> class : SpatRaster
#> dimensions : 5, 5, 4 (nrow, ncol, nlyr)
#> resolution : 72, 36 (x, y)
#> extent : -180, 180, -90, 90 (xmin, xmax, ymin, ymax)
#> coord. ref. : lon/lat WGS 84 (EPSG:4326)
#> source(s) : memory
#> names : mean_diff, sd_diff, min_diff, max_diff
#> min values : 0, 0, 0, 0
#> max values : 0, 0, 0, 0
#>
# algorithm_metrics(r, spat_alg = "bootspat_naive", spat_alg_args=list(random="both"))