Skip to contents

Builds several M variants from the same records (thinning and linking distance are computed once) and compares them: area, share of records inside (per group), and overlap with a reference scenario (share of this scenario inside the reference, and the Jaccard index).

Usage

m_scenarios(
  points,
  scenarios = NULL,
  reference = NULL,
  link_km = NULL,
  link_search = c(100, 600),
  link_fallback = c("stop", "upper"),
  link2_max_km = 1000,
  thin_km = 10,
  group = NULL,
  priority = NULL,
  priority_col = "source",
  extent = NULL,
  exclude = NULL,
  crs = "auto",
  coords = NULL,
  points_crs = "EPSG:4326",
  effort = NULL,
  effort_alpha = 0.05,
  effort_min_km = NULL,
  ...
)

Arguments

points

Occurrence records: a data.frame with coordinates (lon/lat or detected column names), a CSV path, an sf object or a terra::SpatVector. Combine modern and fossil records beforehand if both should shape M (e.g. with merge_occurrences()).

scenarios

Named list; each element is a list of arguments of delimit_m() (method, link_mult, corridors, buffer_km, ...). The default compares the Delaunay M at 0.5, 1 and 2 times L, with corridors, the cluster and overall convex hulls, and fixed 100 km buffers.

reference

Name of the reference scenario (default: the first).

Linking distance L in km; NULL (default) = derived from the data.

Range (km) in which the automatic L is searched.

What to do when fewer than three spanning-tree links fall within link_search, so that no L can be derived: "stop" (default) with an explanation and the longest links, or "upper" to use the upper end of link_search as an explicit fallback. The fallback is marked in the result (L_source = "fallback") and in every printout: it is not an estimate from the records.

Upper limit (km) for the second linking distance L2.

thin_km

Thinning cell size (km) before linking; one record per cell (and per group).

group

Optional column (e.g. modern / fossil) thinned separately and reported separately.

priority, priority_col

Sources preferred when thinning (see thin_by_cell()).

extent

Optional c(xmin, xmax, ymin, ymax) in longitude/latitude: records outside are dropped and M is clipped to it.

exclude

Polygons to remove from M (e.g. another mountain system). Records inside them are dropped before M is built.

crs

Equal-area projection used for all geometry. "auto": Lambert azimuthal equal-area centred on the data (polar for circumpolar data).

coords, points_crs

Coordinate columns and their CRS when points is a table.

effort

Optional recording effort: a terra::SpatRaster (or a path) whose first layer gives the effort per cell in any unit, e.g. the records of a target group per cell from gbif_effort_rasters(). With it, each spanning-tree link of at least effort_min_km is tested for crossing a gap that was recorded without finding the species, and a derived L is lowered so that it does not reach across such a gap (see Details).

effort_alpha

The gap is taken as surveyed when the probability of recording no record there, if the species occurred there, is below this value (default 0.05, i.e. about three records expected).

effort_min_km

Shortest link tested (default: the lower end of link_search). Links shorter than a known dispersal distance can be left untested by setting it to that distance.

...

Arguments passed to delimit_m() for every scenario (e.g. add, exclude, extent, link_km). A scenario with method = "simulation" needs env (and optionally simulation) in its own list.

Value

An object of class m_scenarios: a list with areas (the m_area objects) and comparison (a data.frame).

Details

Use it by default, not as an optional check. The choice of calibration area was the most influential factor in simulations of model accuracy, explaining half of its variance, more than regularisation, collinearity treatment and spatial thinning together (Luna et al. 2024). Comparing several delimitations (geometric, simulated with method = "simulation", and the minimal extent of m_minimal()) and reporting how much they differ is therefore part of choosing M, not a supplement to it.

Status. A preENM sensitivity design: the M methods are alternative hypotheses about accessibility, and the comparison shows how much the result could depend on that choice.

References

Luna, S., Pena-Peniche, A., Mendoza-Alfaro, R. (2024) Species distribution model accuracy is strongly influenced by the choice of calibration area. Biodiversity Informatics 18, 43-55. doi:10.17161/bi.v18i.22655

Examples

sim <- simulate_enm_data(seed = 1, n_presence = 150)
sc <- m_scenarios(sim$presence, link_km = 120, thin_km = 5,
                  scenarios = list(delaunay = list(),
                                   hull = list(method = "cluster_hull"),
                                   buffer_50 = list(method = "buffer",
                                                    buffer_km = 50)))
sc$comparison
#>    scenario       method area_km2 records_inside_pct share_in_reference_pct
#> 1  delaunay     delaunay   390427                100                  100.0
#> 2      hull cluster_hull   409762                100                   95.3
#> 3 buffer_50       buffer   350657                100                  100.0
#>   jaccard_with_reference
#> 1                  1.000
#> 2                  0.953
#> 3                  0.898
plot_m_area(sc)