Data sourcesBiodiversity data

All biodiversity data—species presence or absence, and abundance—were obtained from the Projecting Responses of Ecological Diversity in Changing Terrestrial Systems (PREDICTS) project28, a meta-database compiled from independent source studies and inventories. We combined the two publicly available releases of the database (from 2016 and 2022)52,53 into one dataset. Before filtering (see further down), the combined dataset contained data from 817 studies comprising 35,736 sampling sites in 101 countries, with 4,318,808 unique records across 53,925 species, collected between 1984 and 2018. The PREDICTS data mainly covers animals and plants, with the most common groups being insects and other arthropods, vascular plants, and vertebrate animals. Despite efforts to balance the data taxonomically, vertebrates are over-represented relative to their true diversity, while fungi and non-arthropod invertebrates are underrepresented. Geographically, the dataset has gaps in line with most biodiversity data sources; high-income regions such as North America and Europe are well sampled relative to their underlying biodiversity, and some tropical areas in Latin America also have high coverage, while there are large gaps in Africa and parts of Asia. See Extended Data Fig. 1 and Extended Data Fig. 2 for an overview of the PREDICTS data used in the modelling. In 255 of the source studies (prefiltering), spatially adjacent sampling sites had been grouped into spatial blocks, which were utilized for the SBM.

Human pressure data

The predominant land-use type and land-use intensity at each sampling site has been categorized by the PREDICTS team on the basis of information in the source studies28. Land-use categories include primary vegetation, secondary vegetation (split into young, intermediate, mature or indeterminate age), plantation forest, cropland, pasture and urban, while use intensity has been classified as minimal, light or intense. Data on human population density, expressed as the number of people per 1 km2, came from the Gridded Population of the World, v4.11 (GPWv4.11) dataset54, based on the 2010 round of Population and Housing Censuses (conducted 2005–2014) and adjusted to match the United Nations World Population Prospects country totals. The population data represents extrapolated numbers for the years 2000, 2005, 2010, 2015 and 2020. Data on road networks were taken from the Global Roads Open Access Data Set, v1 (gROADS)55, a global layer of joined country road networks adjusted for topology. Data were collected between 1980 and 2010, with limited information on original road construction dates.

Bioclimatic and topographic data

Bioclimatic variables, such as annual averages, seasonality and extreme values of temperature and precipitation, were based on the WorldClim v2.1 dataset56, frequently used in species distribution models and other biodiversity studies. The data represent average values over the period 1970–2000. Data on elevation, slope and terrain roughness came from the EarthEnv repository57, constructed from global digital elevation models derived from satellite imagery and LiDAR measurements.

The spatial resolution of the PREDICTS land-use data depends on the specific sampling extent of a given site in each source study28 (which is available for only 13.1% of sampling sites). The resolution of the population density, bioclimatic and topographic variables is 30 arc-seconds (approximately 1 km2 at the Equator)54,56,57. The spatial accuracy of the road network data varies by country55. Manual classification of land-use type and intensity could have introduced inconsistencies within and between studies28. Because predominant land-use is a categorical attribute, there can be underlying differences in habitat conditions within the same class that cannot observed.

Biodiversity metrics

We modelled two biodiversity metrics: the GMA58, an alpha diversity metric, and the BC similarity59, a beta diversity metric. Combined, they provide insights into the relative level of community richness, abundance, evenness and compositional similarity between areas, and are suitable for detecting changes in biodiversity58. If we let asi represent the abundance of species s at sampling site i, and let Si represent the total number of species at the site, the GMA of that site can be calculated as

$${y}_{i}=\exp \left(\dfrac{1}{{S}_{i}}\mathop{\sum }\limits_{s=1}^{{S}_{i}}\,\text{ln}\,({a}_{si}+1)\right)-1,$$

where 1 was added to each abundance value before logarithmic transformation to accommodate zero values and subtracted after back-transformation. The log transformation dampens the contribution of highly abundant (perhaps generalist or opportunistic) species. For a given total site abundance, a more even distribution of abundance across several species results in a greater GMA. For beta diversity, the BC similarity between two sampling sites i and j is given by

$${y}_{ij}=\dfrac{2\mathop{\sum }\nolimits_{s = 1}^{S}\min ({a}_{si},{a}_{sj})}{\mathop{\sum }\nolimits_{s = 1}^{S}\left({a}_{si}+{a}_{sj}\right)},$$

where S represents the total number of species found at any of the sites. This is equivalent to an abundance extension of the Sørensen index. The index takes a value of 0 if there are no shared species between sites i and j, and a value of 1 if the species and their abundances are identical between the two sites (which is highly unlikely). Because the focus of this study is on models used to estimate biodiversity intactness, the BC similarity was calculated between reference sites, consisting of minimally used primary vegetation sites, and all other sites within each study. The reference site baseline approach follows the one used in the BII20 and is similar to the implementation of MSA in GLOBIO22.

One challenge with biodiversity meta-databases is that the abundance distributions from different source studies will be greatly influenced by taxonomic scope, biogeographic area and sampling method. Furthermore, while abundance is often expressed as a count of individuals, it can also be a proportion or density. The most viable approach we found, following the BII20, was to normalize the GMA values within each study to a common 0–1 scale, by dividing them by the respective within-study maxima:

$${y}_{i}^{{\rm{norm}}}=\dfrac{{y}_{i}}{\max (\;{y}_{1},\ldots ,{y}_{I})}.$$

For the BTM, biome–taxa metric scaling was performed within both study and broad taxonomic group. The BC index is already expressed on a 0–1 scale, so no further processing was needed. For simplicity, we let yi denote the normalized values from hereon. Although the sampling method is consistent between sampling sites within a given PREDICTS source study, sampling effort between sites can vary. Alpha diversity metrics used effort-corrected abundance (provided in the PREDICTS data). For beta diversity, we retained studies with a constant reported sampling effort and more than one taxon, and calculated BC similarity from the reported abundance measurements. Because both diversity metrics require abundance data, we filtered out studies that recorded only presences and absences. To mitigate the influence of extreme abundance values, we calculated an upper outlier threshold of Q3 + 1.5× interquartile range from the all-species response within each study. We excluded alpha diversity sites or beta diversity site pairs whose all-species response (used for the SBM and BRM) exceeded this threshold and applied the same site or site-pair exclusions to the taxon-stratified datasets (used for the BTM).

The distributions of the alpha diversity (GMA) and beta diversity (BC similarity) metrics are shown in Extended Data Fig. 3a–d. They are non-symmetric and quite heavily skewed to the right. The shapes are similar, but the GMA distributions have greater means than the BC indices, as a compositional similarity metric to a greater extent reflects natural species turnover across the landscape. There is an inflation of zeros in both distributions, and an inflation of ones in the GMA data. A site-level abundance of zero can either be the result of true absence of the surveyed species, or the result of imperfect detection, a well-known issue in biodiversity data. In the best case, noise that arises from imperfect detection is randomly distributed across studies and sites, but we acknowledge that there could be more systematic detection biases in the data. In addition, studies that surveyed only a small number of species are more likely to have zeros at the site level. However, there was no feasible way to construct a separate detection probability model42,60 for such a heterogeneous dataset using the data that we had available. The inflation of zeros in the BC distribution is the result of a mix of observed zero abundances and complete dissimilarity in species composition between sites. The inflation of ones in the GMA data is an artefact of the normalization procedure described above, as every study will contribute a 1 (its maximum abundance site) to the overall data pool.

In addition to the requirement on abundance data, studies with fewer than ten sampling sites were excluded from both datasets. Beta diversity studies were additionally required to contain at least three minimally used primary vegetation reference sites. Still, it should be noted that many source studies still contain very few sites (Extended Data Fig. 3e,f). There is a risk that such small studies contribute more noise than signal to the overall pool of data used to train the models. This is because there are not enough observations from the context of a given study to reliably relate its species observations to different human pressures and environmental conditions. Through inspection of study-level histograms, we found that ideally 25–50 sites per study would be required to produce somewhat continuous distributions of data at the study level. Some of this was alleviated by pooling data across studies, but biases can still persist in model parameters and predictions.

The BTM used taxonomic groups as part of the hierarchical model structure (Extended Data Fig. 6). Because some larger studies had sampled species across several such taxonomic groups, sampling sites were consequently split into multiple observations. This had only a very minor effect on the number of observations and the distribution of response variables (Extended Data Fig. 3a–d). The BTM alpha model had 25,104 observations in total, in comparison with the 24,861 sampling sites in scope, which also equalled the number of observations in the SBM and BRM. Because the BC similarity dataset contained more than 400,000 unique site pairs after standard filtering, we used subsampling to obtain a tractable but representative dataset for model training and evaluation. The sampling was designed to retain all studies with at least three reference sites, while preventing large studies, with many sites and reference sites, from becoming too dominant.

We first set a nominal global sampling target of K = ⌊f × Npairs⌋, where Npairs was the total number of distinct site pairs and f = 0.10. For each study s, containing ns comparison sites and rs reference sites, we calculated a sampling weight \({w}_{s}=\sqrt{{n}_{s}{r}_{s}}\). The target number of pairs contributed by each study was then

$${k}_{s}=\min \left({k}_{\max },\max \left({k}_{\min },\left\lfloor K\dfrac{{w}_{s}}{{\sum }_{j}{w}_{j}}\right\rfloor \right)\right),$$

where \({k}_{\min }=400\) and \({k}_{\max }\,=\,\text{2,000}\). These bounds increased the relative contribution of smaller studies while limiting the dominance of the largest studies. Within each study, we randomly selected approximately \(\sqrt{{k}_{s}}\) comparison sites and sufficient reference sites to form approximately ks pairs, subject to the numbers of each available. If the resulting combinations exceeded ks, we randomly subsampled them to ks pairs. This resulted in a total of 38,010 site pairs that were consistent across all models, used in the SBM and BRM, and 38,273 site-pair–taxa observations for the BTM.

Model covariates

Variables based on land-use28, population density54 and road network density55 data, formed the core of all models in the study20. For land-use, the class and its intensity were combined into a new set of categorical variables; records where this information was unknown were filtered out. Minimally used plantation forest was grouped with lightly used secondary forest, and other plantation forest (light and intense use) was grouped with intensely used secondary forest, following previous work20. The categorical land-use variables were one-hot encoded, with the model intercepts representing minimally used primary vegetation reference sites. Human population density and road network density, log-transformed to reduce skewness, were also used as human pressure variables. Human population density and road network density represented mean values within circular buffers of 10 km radius around the sampling locations. In addition, the following bioclimatic and topographic variables were included: annual mean precipitation and temperature, temperature and precipitation seasonality, elevation and terrain roughness. Bioclimatic and topographic variables leveraged mean values within circular buffers of 1 km radius. A complete list of model covariates can be found in Extended Data Table 1. We did not include any interaction effects owing to the small number of observations in many studies (and to some extent, hierarchical groups), implying that the models were already highly parameterized, and even overparameterized to some extent.

Sampling-site coordinates were projected from EPSG:4326 to the corresponding local Universal Transverse Mercator (UTM) coordinate system. Circular buffers of the specified radii were generated in metres and then reprojected to EPSG:4326 for extraction from the global raster layers. The local UTM projections ensured that the calculated values were comparable across all locations, regardless of distance to the equator. For each raster dataset (human population density, bioclimatic and topographic) the mean value of each polygon was calculated, including partially covered pixels. For the road network data, a similar approach was used to derive road density as the combined length of all roads within each polygon. Population density data were interpolated between the available years in the GPW dataset, and back to the earliest PREDICTS data (1984), assuming an exponential growth rate61. The population densities were matched to the sampling year of each site; the other covariates were static layers. Missing environmental covariates were imputed sequentially using a simple method, first taking the mean values within a given spatial block and study if available, then resorting to the mean values within the whole study, and finally to the mean across all data (which makes the observation uninformative for the model, but avoids dropping otherwise valid observations). The alpha diversity model variables listed above were evaluated for collinearity (not shown). The highest pair-wise correlations were −0.81 (annual mean temperature and temperature seasonality), 0.61 (elevation and terrain roughness) and −0.59 (annual precipitation and temperature seasonality). Due to our focus on predictive evaluation over parameter inference, we chose to retain all listed covariates.

For the beta diversity (BC) models, the land-use variables described the conditions at the non-reference site in each pair, as the reference sites constituted the model intercepts (minimally used primary vegetation). Differences in the human population and road density variables were calculated for each site pair. We included the environmental Gower distance46, calculated using study-specific environmental ranges, as a control for natural environmental turnover between paired sites. The Gower distances were calculated using annual mean temperature, temperature seasonality, annual precipitation, precipitation seasonality, minimum and maximum temperature of the coldest and warmest month, the precipitation of the driest and wettest month, elevation and terrain roughness, all summarized at the 1 km radius scale. The distance was transformed as \(\log (1+{d}_{{\rm{Gower}}})\) before model fitting.

Model structures and implementationLikelihood function

The GMA and BC distributions are non-symmetric and bounded between 0 and 1, with substantial inflation of zeros and some inflation of ones in the GMA case (Extended Data Fig. 3a–d). This suggests that a zero-inflated or zero-one-inflated beta distribution would be the most appropriate likelihood function to describe the data62. The beta distribution is 0–1 bounded and can have a more or less symmetrical shape depending on its parameters. However, because our goal was to predict biodiversity on highly aggregated levels, it seemed counterproductive to explicitly model the zero-inflation, as true absences of entire species groups in a given area are unlikely. Furthermore, the inflated ones are scaling artefacts (due to the interstudy normalization) that did not warrant explicit modelling either. We therefore assumed a regular beta likelihood function, with a logit link function, for all models63. For the model sampling to work, we clipped the response values to (10−6, 1 − 10−6).

Modelling framework

Although previous global biodiversity intactness modelling efforts have utilized frequentist mixed-effects models18,20,22,23, we decided to implement the models using a Bayesian hierarchical framework. This was an enabler for fitting the ecologically structured models (BRM and BTM), as the framework can effectively leverage statistical strength across groups and handle overparameterization in cases of sparse data42,43,44, with regularization through weakly informative priors43. The models were implemented in PyMC64, using the No-U-Turn Sampler (NUTS)65 with a numpyro66 backend. For all experiments, we ran four parallel sampling chains for stability, using 1,000 tuning samples that were discarded and 1,000 posterior draws. A high target acceptance rate of 0.95 was used to avoid problems when sampling from the complex posterior distribution. Due to the high number of small studies and ecological groups, it was hard to avoid some parameters with small effective sample sizes and \(\hat{R\,} > \,\text{1.01}\) (ref. 67). While this could indicate issues in the sampling, the overall performance results were robust also when using fewer iterations than in the final runs.

Study-block model

The SBM model structure consisted of fixed effects, parameters representing average values over all studies in the dataset, and random effects, which quantify group-level variation around the fixed effects39,68. The study-level random intercepts and slopes accounted for interstudy differences in geographic and taxonomic scope, environment and sampling. For studies that grouped spatially adjacent sites into blocks, corresponding intercepts were included to capture intrastudy differences. Because all site-level species observations were aggregated to form the response variables, the fixed effects were estimated as an average of all geographies and taxa in the data18,19,20.

We let β denote the fixed effects and let γs denote the study-level random effects, for the study s that site i belongs to. The spatial block intercepts are denoted by γsb(s) for each block sb within study s. These different effects constitute a hierarchical structure, from the population of all studies to individual source studies, and from studies to blocks. As noted above, we used a beta likelihood with a logit link function g( ⋅ ) across all models63. The mean of yi, conditional on the covariates, is denoted by μi. The site-level regression model for GMA can then be written as

$$g({\mu }_{i})={{\bf{x}}}_{i}^{\top }{\boldsymbol{\beta }}+{{\bf{x}}}_{i}^{\top }{{\boldsymbol{\gamma }}}_{s}+{\gamma }_{\mathrm{sb}(s)}={\eta }_{i},$$

where μi = g−1(ηi). We fitted a full set of random slopes at the study level, such that the random-effect covariates are the same as the fixed-effect ones xi. The γs parameters were assumed to be uncorrelated and vary around the fixed effects with mean zero.

In the beta diversity model, yij denotes the BC similarity between some site i and a reference site j, within the context of a study s. In addition to the regular covariates xi for the non-reference site, we let zij denote the set of delta measures calculated between the two sites: the difference in the population and road density, and the environmental distance. If we let βΔ and \({{\boldsymbol{\gamma }}}_{s}^{{\Delta }}\) denote the parameter vectors associated with these difference terms, we can write the beta diversity model as

$$g({\mu }_{ij})={{\bf{x}}}_{i}^{\top }{\boldsymbol{\beta }}+{{\bf{z}}}_{ij}^{\top }{{\boldsymbol{\beta }}}^{{\Delta }}+{{\bf{x}}}_{i}^{\top }{{\boldsymbol{\gamma }}}_{s}+{{\bf{z}}}_{ij}^{\top }{{\boldsymbol{\gamma }}}_{s}^{{\Delta }}+{\gamma }_{\mathrm{sb}(s)}.$$

For the dispersion parameter of the beta distribution likelihood, we sampled a raw scale parameter from a beta distribution, σraw ~ Beta(a, b), using a = 2, b = 12 for the GMA model and a = 2, b = 20 for the BC similarity model. We then defined a mean-dependent dispersion \(\sigma ({\mu }_{i,t})={\sigma }_{{\rm{raw}}}\sqrt{{\mu }_{i,t}\left(1-{\mu }_{i,t}\right)}\) and used it to parameterize the beta likelihood:

$${y}_{i,t} \sim {\rm{Beta}}\left({\mu }_{i,t},\sigma ({\mu }_{i,t})\right).$$

The priors of the SBM were kept loose in order to not constrain the estimated study heterogeneity, but constrained enough for the sampling to run efficiently.

Biome–realm and biome–taxa models

The SBM model structure is centred around the data collection process, with studies that sampled sites which were sometimes organized into spatial blocks. In the BRM and BTM, we instead designed the hierarchical structure based on the biomes and realms where each site is located, and the taxonomic groups that were sampled at that site. In both models, this was implemented as a two-level hierarchy. Biomes constituted the first hierarchical level in both models. These are distinct in their environmental conditions and underlying biodiversity patterns, which suggests that the effect sizes of both natural and anthropogenic drivers will be different between them34,40. In the BRM, the second level subdivided biomes by biogeographic realms, to form regional biomes40 (Extended Data Fig. 5). In the BTM, the second level instead consisted of broad taxonomic groups, which previous studies have also suggested differ in their responses22,35,40: plants, vertebrates, invertebrates, fungi and other taxa (Extended Data Fig. 6).

We let b = 1, …, B denote biomes, r = 1, …, R biogeographic realms and t = 1, …, T taxonomic groups. Furthermore, r(b) indicates the partition of a given biome into realms, and t(b) the equivalent split of biome data by taxonomic groups. Note that realms can span multiple biomes and vice versa, so this is not a unique one-to-one mapping (and the same of course holds for the taxonomic groups). For the group-level model parameters, intercepts are denoted by α and other parameters by β. The alpha diversity (GMA) model for site i in the regional biome r(b) can be written as

$$g({\mu }_{i})={\alpha }_{r(b)}+{{\bf{x}}}_{i}^{\top }{{\boldsymbol{\beta }}}_{r(b)}.$$

Like the SBM, we assumed normal and uncorrelated priors for the model parameters, with half-normal priors on the variance terms. At the population-level, the following hyperpriors were used:

$$\begin{array}{c}{\mu }_{\alpha }^{\mathrm{GMA}}\sim{{ \mathcal N }}(\mathrm{log}\mathrm{it}(\text{0.35}),\,{\text{0.25}}^{2}),\\ {\mu }_{\beta }^{(k)}\sim{{ \mathcal N }}(0,\,{\text{0.18}}^{2}),\qquad k=1,\ldots ,K,\end{array}$$

where the K is the number of regression parameters. These priors define distributions over the population-level model parameters, which sit at the top of the hierarchy. The priors at the first hierarchical level (biomes) were drawn from the hyperpriors in the following way:

$$\begin{array}{l}{\tau }_{\alpha ,1}\sim\mathrm{HalfNormal}(\sigma =\text{0.15}),\\ {\alpha }_{b}\sim{{ \mathcal N }}\left({\mu }_{\alpha },\,{({c}_{b}{\tau }_{\alpha ,1})}^{2}\right),\\ {\tau }_{\beta ,1}\sim\mathrm{HalfNormal}(\sigma =\text{0.07}),\\ {\beta }_{b}^{(k)}\sim{{ \mathcal N }}\left({\mu }_{\beta }^{(k)},\,{({c}_{b}{\tau }_{\beta ,1})}^{2}\right).\end{array}$$

The scaling factor cg, adapted the amount of regularization—through the prior variance—on the group-level model parameters as a function of the number of studies in each biome–realm or biome–taxa group.

$${c}_{g}=\min \left\{1,\,\max \left[\,\text{ln}\,({n}_{g})-1,\,\epsilon \right]\right\},$$

where ng is the number of studies represented in group g and ϵ = 10−6. In a similar way, the priors at the second level (biome–realm) inherited from their respective parent biomes at the first level, but with tighter priors on the slope variances. Let g(b) denote either realm within biome for the BRM or taxonomic group within biome for the BTM:

$$\begin{array}{l}{\tau }_{\alpha ,2}\sim\mathrm{HalfNormal}(\sigma =\text{0.15}),\\ {\alpha }_{g(b)}\sim{{ \mathcal N }}\left({\alpha }_{b},\,{({c}_{g(b)}{\tau }_{\alpha ,2})}^{2}\right),\\ {\tau }_{\beta ,2}\sim\mathrm{HalfNormal}(\sigma =\text{0.05}),\\ {\beta }_{g(b)}^{(k)}\sim{{ \mathcal N }}\left({\beta }_{b}^{(k)},\,{({c}_{g(b)}{\tau }_{\beta ,2})}^{2}\right).\end{array}$$

The numeric prior values above were chosen based on iterative prior predictive checks, to obtain a prior predictive distribution reasonably similar to the observed data (Extended Data Fig. 3a,c) and achieve a relatively high degree of model regularization.

Next, the beta diversity model can be expressed as

$$g({\mu }_{ij})={\alpha }_{r(b)}+{{\bf{x}}}_{i}^{\top }{{\boldsymbol{\beta }}}_{r(b)}+{{\bf{z}}}_{ij}^{\top }{{\boldsymbol{\beta }}}_{r(b)}^{{\Delta }}.$$

The prior structure was identical to the alpha diversity model, but we assumed slightly different hyperpriors due to the lower mean and longer tail of the BC similarity distribution (Extended Data Fig. 3b,d):

$$\begin{array}{l}{\mu }_{\alpha }^{\mathrm{BC}}\sim{{ \mathcal N }}\left(\mathrm{log}\mathrm{it}(\text{0.25}),\,{\text{0.25}}^{2}\right),\\ {\mu }_{\beta }^{(k)}\sim{{ \mathcal N }}(0,\,{\text{0.18}}^{2}),\qquad k=1,\ldots ,K.\end{array}$$

Because many biogeographic and taxonomic groups contained only a few studies and sites (Extended Data Fig. 3e,f), there was a risk that the estimated group-level parameters would become too specific to a few studies, rather than generally applicable to the group at large. To prevent this from producing overoptimistic accuracy numbers, especially for interpolation, we implemented a ’roll-up’ scheme for out-of-sample predictions. Here, any biome–realm or biome–taxa groups with fewer than five studies or fewer than 100 sampling sites in each training fold, including fewer than five references sites for beta diversity, were assigned the parameters of their respective parent at the biome level for prediction. If the threshold was still not met at the biome level, the population-level posterior parameters were used for predictions.

Biome–realm regression analysis

The multivariable regression analysis reported alongside Fig. 5c,d used ordinary least squares, with biome–realm Spearman rank correlations calculated from predictions pooled across folds as the response variable. Six covariates were standardized before fitting: total number of sampling sites (log-transformed), median number of sites per study (log-transformed), median number of taxonomic orders per study (log-transformed), median number of species per study–order combination (log-transformed), environmental heterogeneity quantified as the average Gower distance between pairs of sites in scope, and the percentage of response values more than one interquartile range below the first quartile or above the third quartile. Total number of studies was excluded due to collinearity with other covariates. Statistical significance was assessed using 95% confidence intervals for the coefficients. Sample sizes were n = 41 biome–realms for alpha diversity and n = 37 for beta diversity.

CV and performance metrics

We evaluated model generality and performance using two complementary CV approaches. Five CV folds were used in all model runs, with stratified sampling using biomes as strata. Continuous variables were standardized before model training using the training data, with the same fitted scaler applied to the test data. The first approach, using ’standard’ CV, assessed how well models could make predictions in environmental and taxonomic contexts similar to the data they were trained on. In other words, this evaluated model interpolation performance (generalizability) from sample to sampled population. The folds were generated by sampling at the site level among all studies within a biome. This implies that sites from a given study were generally split among several folds, creating overlap in studies, but not sites, between folds. In the BTMs, fold assignment was still done at site level, keeping multiple taxonomic units for a given site in the same fold, if present. For the beta diversity runs, sampling into folds was based on the non-reference site in each pair, meaning the same reference site used as baseline could be part of both training and test data. We deemed this to be acceptable given the relatively few reference sites in many studies, which would otherwise have led to very unbalanced folds. The second approach, based on cross-study validation45, was used to assess how well the models could make predictions in new contexts, that is, their extrapolation performance (transferability). In this case, folds were constructed by sampling at the study level, such that all sites from a given study ended up in a single fold. The cross-study validation approach led to a clear spatial and environmental separation of training and test data, while also reflecting taxonomic and methodological differences between source studies. Although the number of studies per fold were roughly equal, one consequence of the cross-study procedure was that folds in some iterations became unbalanced in terms of the number of sites, due to the large spread in the size of different studies.

We used three complementary performance metrics to evaluate the models. The Spearman rank correlation provides a measure of how good a model is at ranking higher- and lower-diversity sites, which is crucial for real-world decision-making:

$${\rho }_{s}=\dfrac{\mathop{\sum }\nolimits_{i = 1}^{n}({r}_{i}-\bar{r})({\widehat{r}}_{i}-\bar{\widehat{r}})}{\sqrt{\mathop{\sum }\nolimits_{i = 1}^{n}{({r}_{i}-\bar{r})}^{2}}\sqrt{\mathop{\sum }\nolimits_{i = 1}^{n}{({\widehat{r}}_{i}-\bar{\widehat{r}})}^{2}}},$$

where ri = rank(yi) and \({\widehat{r}}_{i}={\rm{rank}}({\widehat{y}}_{i})\).

Residual-based R2 evaluates the squared errors of the model predictions compared with a baseline of predicting the mean of the test data, where the squared terms penalize large deviations:

$${R}^{2}=1-\dfrac{\mathop{\sum }\nolimits_{i = 1}^{n}{({y}_{i}-{\widehat{y}}_{i})}^{2}}{\mathop{\sum }\nolimits_{i = 1}^{n}{({y}_{i}-\bar{y})}^{2}}.$$

The final performance metric was the MAE. Because the response variables were on a 0–1 scale, this metric can be interpreted as the average percentage point deviation between predicted and observed values:

$${\rm{MAE}}=\dfrac{1}{n}\mathop{\sum }\limits_{i=1}^{n}\left\vert{\;y}_{i}-{\widehat{y}}_{i}\right\vert .$$

Software used

All data processing, modelling, analysis and visualization were performed in Python 3.11.14 using a reproducible Conda environment. The principal packages and locked versions were NumPy 2.4.1, pandas 3.0.0, Polars 1.15.0, SciPy 1.17.0, scikit-learn 1.8.0, statsmodels 0.14.6, PyMC 5.21.1, PyTensor 2.28.3, NumPyro 0.19.0, JAX and JAXlib 0.7.2, ArviZ 0.23.1, xarray 2025.12.0, pymer4 0.8.2, Gower 0.1.2, Matplotlib 3.10.8, seaborn 0.13.2, GeoPandas 1.1.2, pyproj 3.7.2, pygeoprocessing 2.4.10, rasterstats 0.20.0 and UTM 0.7.0. The complete environment specification and lockfile are available with the source code.

Reporting summary

Further information on research design is available in the Nature Portfolio Reporting Summary linked to this article.