Compares the environmental niches of two or more groups of records: species, lineages, cytotypes, or native and introduced ranges (a grouping column handles within-species comparisons, e.g. Zhang and Kubota 2021). Follows the framework of Broennimann et al. (2012), as in ecospat and ENMTools (Warren et al. 2021):
Usage
niche_overlap(
records,
env,
group = "group",
background = NULL,
space = c("pca", "raw"),
vars = NULL,
log_vars = NULL,
grid = 100,
correct = TRUE,
marginal_records = 0.05,
truncate = FALSE,
marginal_env = 0,
n_rep = 100,
tests = c("equivalency", "similarity"),
n_background = 10000,
predictions = NULL,
seed = NULL,
coords = NULL,
points_crs = "EPSG:4326",
crs = NULL
)Arguments
- records
Records: a data.frame (or CSV path,
sf, SpatVector) with coordinates and agroupcolumn, or a named list of record tables, one per group.- env
Predictor rasters shared by all groups.
- group
Column with the group of each record.
- background
Available environment of each group:
NULL(the whole raster, the same for all groups), one area for all groups, a named list of areas per group (polygons,sf, SpatVector, anm_areafromdelimit_m(), or a raster whose non-NA, non-0 cells are the area), or a data.frame of background points with coordinates and thegroupcolumn. Comparisons of groups with different histories (e.g. native and invaded ranges) should give each group its own accessible area; the choice of M changes overlap and similarity tests markedly (Qiao et al. 2017).- space
"pca"or"raw".- vars
For
space = "raw", the two predictors (default: the first two layers).- log_vars
Predictors to log-transform before the PCA (default: Bioclim precipitation amounts, as in
thin_environment()).- grid
Number of grid cells per axis of the density estimate.
- correct
Divide the density of records by the density of the environment (Broennimann et al. 2012).
- marginal_records
Share of records at the lowest densities left out of the occupied envelope used for expansion, stability, unfilling and the plot: cells below the density at that quantile of the records are not occupied. Default 0.05: the niche holds 95% of the records (Lo Parrino et al. 2023); with 0 the kernel tails make nearly the whole space "occupied". D, I and breadth use the full densities, as ecospat does by default.
- truncate
Also compute D, I and breadth from densities set to 0 outside the occupied envelope (
marginal_records), as ecospat does withth.sp > 0. DefaultFALSE: in simulations with known overlap (uniform niches in a uniform environment; 100 replicates of 20, 50 and 200 records per group), truncation lowered D in every case, e.g. for a true D of 0.5 a mean of 0.40 instead of 0.48 with 200 records and 0.32 instead of 0.46 with 20, and raised its error; it only brought D of fully separate niches from 0.007 to exactly 0. The equivalency and similarity tests use the same choice.- marginal_env
Share of the rarest available environments ignored in the niche dynamics (0 = none; 0.25 = above the 25th percentile).
- n_rep
Number of replicates of each test (0 = no tests).
- tests
"equivalency"and/or"similarity".- n_background
Number of background points sampled per group.
- predictions
Optional suitability rasters, one layer per group (named as the groups), for overlap in geographic space.
- seed
Optional random seed.
- coords
Optional names of the x/longitude and y/latitude columns when points are tabular. Detected automatically if
NULL.- points_crs
CRS of tabular coordinates (default WGS84,
"EPSG:4326").- crs
Deprecated: the former name of
points_crs, still accepted with a warning.
Value
A list of class niche_overlap: pairs (one row per pair of
groups: D, I, expansion, stability, unfilling and, with
tests, p, ses and verdicts, and with predictions, geo_D,
geo_I, geo_rho), groups (records, background points and breadth
per group), null (the null distributions), densities (the grids),
space (axes, variance explained, loadings) and settings.
Details
Environmental space. The predictor values of the backgrounds of all groups are pooled and summarised by a principal component analysis (the PCA of
thin_environment(), precipitation amounts log-transformed); the first two axes form the space (space = "pca"). Withspace = "raw", two standardised predictors are used instead (vars).Densities. The space is cut into a
gridxgridlattice; the densities of records and of available environments (the background) of each group are estimated with a Gaussian kernel (reference bandwidth, as in ecospat). The occupancy is the density of records divided by the density of the environment (correct = TRUE, Broennimann et al. 2012), so that common environments do not look preferred.Overlap. Schoener's
D = 1 - 0.5 * sum(|p1 - p2|)and Warren'sI = 1 - 0.5 * sum((sqrt(p1) - sqrt(p2))^2), from the two occupancies scaled to sum to 1: 0 = no overlap, 1 = identical. This is the corrected Hellinger indexI_corof Rodder and Engler (2011), used by ecospat and ENMTools; the original form1 - H / 2(Warren et al. 2008) cannot fall below 0.29.Breadth. Levins' B2 (standardised inverse Simpson index of the occupancy over the cells with available environment): 0 = one cell, 1 = all cells equally.
Niche dynamics of the second group relative to the first (Guisan et al. 2014):
expansion(share of the second group's occupancy in environments the first does not occupy),stability(the rest) andunfilling(share of the first group's occupancy in environments the second does not occupy), within the environments available to both.marginal_envremoves rare environments (e.g. 0.25 for the 75th percentile used by Lo Parrino et al. 2023),marginal_recordsthe most marginal records (e.g. 0.05 for 95% of the records).
Tests (n_rep replicates each), reported with a null distribution,
p-values and a standardised effect size ((observed - null mean) / null SD), as in null_model_test() and transfer_bias_test():
Equivalency (identity) test: the records of both groups are pooled and randomly re-split into groups of the same sizes (Warren et al. 2008).
p_lowersmall = the niches are less alike than random splits: not equivalent.Similarity (background) test, in both directions: the occupancy of one group is compared with that of random points from the background of the other (Warren et al. 2008, ENMTools).
p_highersmall = more similar than expected from the environments available (niche conservatism);p_lowersmall = less similar (divergence).
Geographic overlap. ENMTools first measured overlap between model
predictions in geographic space. With predictions (one suitability
raster per group, layer names = groups), D, I and the Spearman
correlation of the suitabilities are added (prediction_overlap()).
They describe where the groups could co-occur in the area mapped, not
their niches: they depend on the extent and on which environments it
contains, so niche comparisons are better made in environmental space
(Broennimann et al. 2012).
Sensitivity. Whether a niche shift is detected can depend on the
background, the variables, the space and the thinning more than on the
species (Lo Parrino et al. 2023); overlap_scenarios() repeats the
analysis across such choices.
References
Broennimann, O., Fitzpatrick, M.C., Pearman, P.B., Petitpierre, B., Pellissier, L., Yoccoz, N.G., Thuiller, W., Fortin, M.-J., Randin, C., Zimmermann, N.E., Graham, C.H., Guisan, A. (2012) Measuring ecological niche overlap from occurrence and spatial environmental data. Global Ecology and Biogeography 21, 481-497. doi:10.1111/j.1466-8238.2011.00698.x
Warren, D.L., Glor, R.E., Turelli, M. (2008) Environmental niche equivalency versus conservatism: quantitative approaches to niche evolution. Evolution 62, 2868-2883. doi:10.1111/j.1558-5646.2008.00482.x
Qiao, H., Escobar, L.E., Peterson, A.T. (2017) Accessible areas in ecological niche comparisons of invasive species: recognized but still overlooked. Scientific Reports 7, 1213. doi:10.1038/s41598-017-01313-2
Warren, D.L. et al. (2021) ENMTools 1.0: an R package for comparative ecological biogeography. Ecography 44, 504-511. doi:10.1111/ecog.05485
Guisan, A., Petitpierre, B., Broennimann, O., Daehler, C., Kueffer, C. (2014) Unifying niche shift studies: insights from biological invasions. Trends in Ecology & Evolution 29, 260-269. doi:10.1016/j.tree.2014.02.009
Lo Parrino, E., Falaschi, M., Manenti, R., Ficetola, G.F. (2023) All that changes is not shift: methodological choices influence niche shift detection in freshwater invasive species. Ecography 2023, e06432. doi:10.1111/ecog.06432
Zhang, Z., Kubota, S. (2021) Integrating intraspecific variation in species distribution models by quantifying niche differentiation. Biological Journal of the Linnean Society 133, 187-201. doi:10.1093/biolinnean/blab021
Rodder, D., Engler, J.O. (2011) Quantitative metrics of overlaps in Grinnellian niches: advances and possible drawbacks. Global Ecology and Biogeography 20, 915-927. doi:10.1111/j.1466-8238.2011.00659.x
Examples
sim <- simulate_enm_data(seed = 1)
pres <- sim$presence
# two "lineages": west and east of the area
pres$group <- ifelse(pres$lon < 19, "west", "east")
no <- niche_overlap(pres, sim$env, n_rep = 19, seed = 1)
no
#> Niche overlap: 2 groups in the PCA environmental space (100 x 100 grid; background: whole area)
#>
#> IN SHORT
#> - east vs west: no or very limited overlap (D = 0.19, I = 0.38). 92% of
#> west's niche lies in environments that east does not occupy, and 94% of
#> east's niche in environments that west does not occupy.
#> - Equivalency test: the niches cannot be told apart from random splits of
#> the pooled records (p = 0.05); with few records the test has little
#> power.
#> - Similarity test: east is as similar to west as random points of its range
#> (p = 0.05); west is as similar to east as random points of its range (p =
#> 0.05).
#> - Only 19 replicates: p-values cannot be smaller than 0.05; use 100 or
#> more.
#>
#> group1 group2 D I expansion stability unfilling eq_p_lower eq_ses
#> east west 0.186 0.384 0.922 0.078 0.944 0.05 -18.049
#> sim12_p_higher sim21_p_higher
#> 1 1
#>
#> Groups:
#> group n_records n_background breadth_B2
#> east 54 4800 0.481
#> west 46 4800 0.398
#>
#> D = Schoener's overlap, I = Warren's (corrected) overlap of the occupancies
#> (record density / environment density); 0 = none, 1 = identical. Grades
#> (below 0.2 no or very limited, 0.2-0.4 low, 0.4-0.6 moderate, 0.6-0.8 high,
#> above 0.8 very high) are those suggested by Rodder and Engler (2011).
#> breadth_B2 = Levins' standardised breadth (0-1). Tests: equivalency p_lower
#> small = not equivalent; similarity p_higher small = more similar than
#> expected (conservatism), p_lower small = less similar. ses = (observed - null
#> mean) / null SD.
plot_niche_overlap(no)
