Main

With agricultural systems dominating Earth’s arable surface6,7, the future of biodiversity and ecosystem services depends on both protected areas and habitats that are found in croplands, grazing lands and tree plantations1. Some agricultural systems have a high capacity to support biodiversity over the short term3,8, yet little is known about their long-term capacity4,5,9,10,11. Studies into the effects of habitat conversion often use short-term sampling methods12,13 that cannot detect potential delayed effects13,14,15 and that limit the inference of land-use interactions with other drivers to determine biodiversity dynamics.

Theory and limited evidence suggest that the full effects of habitat conversion on ecological communities may not be realized for decades or centuries16,17,18 owing to long-term transient dynamics15, historical contingency19, extinction debt20, invasion dynamics21 and eco-evolutionary feedback effects22. Moreover, agricultural practices create habitats that are different in almost all aspects, from vegetation to climate, and these new conditions may interact to intensify the changes in biodiversity23,24. A better understanding of the long-term changes in biodiversity is crucial to improve forecasting of ecosystem dynamics and the effectiveness of conservation interventions15,25,26,27.

To investigate the long-term response of biodiversity to habitat conversion, we quantified the temporal shifts in bird communities across forest and countryside landscapes in Costa Rica. The country experienced rapid deforestation for cash crop and cattle production between the 1940s and 1970s; deforestation slowed and began a gradual reversal at the turn of the century28. We conducted transect counts of bird communities over 18 years in 4 distinct life zones: lowland dry forest, lowland wet forest, mid-elevation wet forest and premontane wet forest. Transects were placed in each region (ntransects = 48), with at least three transects situated in each land-cover type in each region: intensive agriculture (n = 18), diversified agriculture (n = 18) and natural forest (n = 12). All transects were visited three times per wet season and three times per dry season, each year (nvisits/transect = 108). Agricultural plots within transects included cattle pasture, coffee inter-cropped with banana and plantain, mixed gardens and monocultures of melon, rice, heart of palm, pineapple and sugar cane. Intensive-agricultural transects contained plots of a single crop type with little other vegetation on or near plots, limiting bird food and habitat resources10 (Supplementary Table 1). By contrast, diversified-agricultural transects contained plots with multiple crop types, were situated near (typically, less than 500 m) remnants of the natural forest (typically 0.1–10.0 ha), and contained bird food and habitat resources in their relatively complex vegetation structure.

We addressed two questions. First, we investigated whether the magnitude of long-term changes in bird communities differed between natural forests and agricultural lands. Second, we analysed how changes in climate and vegetation interacted with land management practices to drive shifts in bird communities. Our data comprise 281,415 individual bird detections of 400 resident and 110 migratory neotropical bird species (n = 510) during 18 years, in combination with daily measures of precipitation, land surface temperature and vegetation.

Overall, diversified-agricultural communities had a high species richness (mean = 71), on par with that of natural-forest communities (mean = 75; likelihood ratio test, P = 0.708) in a managed countryside of interwoven agricultural and natural-forest elements. By contrast, the species richness in intensive agriculture was on average 52% lower than in the natural forest (mean = 36; likelihood ratio test, P < 0.001; Supplementary Table 2). Furthermore, diversified-agricultural plots contained 59% of the endemic species and species included on the IUCN Red List of Threatened Species that were found in forested habitats over the course of this study, while fewer species (39%) were found in intensive-agricultural plots (Extended Data Fig. 1 and Supplementary Tables 35).

Long-term compositional shifts

In answer to our first question, we found that, although all bird communities fluctuated through time, only those communities in agricultural landscapes experienced long-term directional shifts in composition over the 18-year study period (Fig. 1). These changes occurred despite little detectable change in species richness (Extended Data Figs. 2, 3a–c) or total abundance (Extended Data Figs. 2, 3d–f). The absence of long-term shifts in natural forests (Fig. 1b) indicates that the moderate rates of change between years represent fluctuations around a mean community state, rather than cumulative shifts in the species composition through time.

Fig. 1: Long-term directional shifts in bird community structure in agricultural landscapes contrast with forest communities that are temporally less variable.
figure 1

a, Community similarity in each year compared to the first year of study (2000) across three land-cover types. b, No significant directional trends were found in the composition of natural-forest communities. c, d, By contrast, long-term trends were found in both diversified (c) and intensive (d) agriculture. In a, points represent the mean community similarity measured as the Bray–Curtis similarity index for each transect compared with itself in the first year of this study. The error bars show s.e.m. for each land-cover type in each year. In bd, the black lines represent the estimated mean temporal trend in community composition shown in a. Trends were modelled as first-order random walk processes. The shading indicates the 95% Bayesian credible intervals. Positive and negative deviations from the zero line indicate the presence of long-term directional trends in community composition (Supplementary Table 7). bd, nspp. = 510, ntransects = 44, nyears = 18.

In intensive-agriculture habitats, rapid shifts between years (Extended Data Fig. 2a and Supplementary Table 6) accumulated into long-term directional changes in the community composition over the 18 years of study (Fig. 1d). Compositional changes in intensive agriculture were accompanied by a decline in the number of endemic and IUCN red-list species (Fig. 2 and Extended Data Fig. 4). The gradual but sustained decline suggests that these communities were still paying off an extinction debt decades after the intial conversion to agriculture. Although the magnitude of long-term trends was dampened in diversified-agriculture habitats, the slower change between years relative to forests did not preclude the directional shifts in the structure of the bird communities (Fig. 1c). That these changes occurred progressively over time, rather than through abrupt shifts in the species composition between years or through changes in species richness and abundance (Extended Data Fig. 3), demonstrates the persistent, lasting effects that land-use change had on communities14,16,29.

Fig. 2: Long-term declines in the number of endemic, range-restricted and IUCN red-list species in intensive-agriculture, but not forest or diversified-agriculture, habitats.
figure 2

ac, Points depict the median number of IUCN red-list or endemic and range-restricted species observed in natural-forest (a), diversified-agriculture (b) and intensive-agriculture (c) transects in each year. The error bars show the median standard error estimates. Changes in the average richness of endemic, range-restricted and IUCN red-list species were tested by fitting a random walk trend to each land-cover type using Bayesian linear mixed-effects model implemented using integrated nested Laplace approximation (INLA). Long-term declines were driven by species loss in intensive agriculture in the Las Cruces and San Isidro study regions (Extended Data Fig. 4). Estimates of conservation value should be seen as conservative, as some of the rarest and most-threatened species may have gone unobserved. nspp. = 62, ntransects = 44, nyears = 18.

We further explored which guilds were driving these long-term changes in community composition. Guild-level changes were the greatest in intensive-agriculture habitats, with large shifts in the assemblages of insectivorous, nectarivorous and granivorous bird species (Extended Data Fig. 5). Analysing the changes in relative abundance revealed a 28% decline in nectarivores in intensive agriculture and a 19% increase in granivores (Extended Data Fig. 6). The increase in the abundance of granivores accompanied by declines in bird pollinators is consistent with findings of invasion and range expansion of granivores in Costa Rica, following large-scale deforestation throughout Central America over the past century30,31,32,33,34. Shifts in insectivore guilds primarily reflect changes in species identity. Although there were no long-term trends in composition, frugivores in intensive-agriculture habitats exhibited high variation in their species composition from year to year (Extended Data Figs. 5, 6), consistent with the high spatial and temporal variability in the availability of fruit resources in countryside landscapes. Guild-level analyses reveal the idiosyncratic responses that these assemblages have in agricultural landscapes and show that the management system determines the winners and losers of agricultural expansion and intensification.

Climate-driven shifts

To explore our second question on how changes in climate and vegetation interact with land management to drive long-term shifts in bird biodiversity, we compiled daily satellite measurements at each transect. These included land surface temperature and leaf area index (LAI) data for 2002–2017, and daily precipitation data from meteorological stations found within each of the the four study regions for 2000–2014 (Methods). In forests and diversified agriculture, we found no effect of mean annual temperature or precipitation skewness—a measure of drought intensity—on bird communities. By contrast, in intensive agriculture, we found a strong negative effect of mean annual temperature and precipitation skewness on communities: higher temperatures and drier years (particularly in the dry season) drove larger shifts in the composition of bird communities (Fig. 3a, b).

Fig. 3: Annual changes in climate and vegetation drive shifts in bird communities in intensive-agriculture habitats, but not in natural-forest or diversified-agriculture habitats.
figure 3

a, b, Mean annual temperature (a) and drier dry seasons (measured as precipitation skewness) (b) are associated with greater turnover in community composition in intensive-agricultural systems, but not in forest or diversified-agricultural systems. c, In only the intensive-agricultural system, years with greater leafy vegetation (measured as LAI) are associated with slower rates of community change, with no effect in forest or diversified-agricultural communities. In a and c, daily measurements of temperature and LAI were derived from MODIS satellite data of each transect from 2002 to 2017, and mean annual values were used to model the effects on community change in each year compared with the year 2000. In b, daily precipitation measurements were derived from meteorological stations in each region from 2000 to 2014, and annual precipitation skewness was used to model the effect of rainfall distribution throughout the year on community change compared with the year 2000. Points depict posterior means with 95% Bayesian credible intervals. Overlap with zero denotes no effect, negative values are associated with greater changes in communities and positive values with less change in communities. a, c, nspp. = 510, ntransects = 44, nyears = 16. b, nspp. = 510, ntransects = 44, nyears = 15.

Similar to temperature and precipitation effects, yearly variation in the mean LAI had no discernable effects on the composition of communities in forest and diversified agriculture. In intensive agriculture, however, bird communities changed more in years with a lower LAI (Fig. 3c). These findings indicate that the interactive effects of habitat conversion and climate change were the strongest in intensively managed landscapes23 and that bird communities were resistant to climate-induced shifts in forest and diversified-agricultural systems. Our findings also provide evidence of the buffering effect that increasing the amount of leafy vegetation—measured through LAI—can have on moderating the rate of change in agricultural communities.

We used species- and population-level analyses to shed light on the underlying drivers of change in community composition. Specifically, we used a multispecies dynamic occupancy model to understand how land use and climatic traits of the species affected colonization and extinction rates in local communities35. Compared with forests, the probability that a local population persists into the next year decreased by 10% in diversified agriculture and by 18% in intensive agriculture: the probability of population persistence in forest, diversified agriculture and intensive agriculture was 82, 73 and 67%, respectively (Fig. 4a). In agricultural habitats, species affiliated with wetter and cooler conditions were more likely to go locally extinct (Fig. 4b, c), whereas species affiliated with drier and hotter conditions had a higher probability of newly colonizing an agricultural site (Fig. 4d, e). These species-level analyses reveal that deforestation and agricultural intensification drove long-term changes in biodiversity by affecting local colonization and extinction rates. However, the risk of local extinction was not uniform across all species, and there was a strong selection for the colonization of species affiliated with a drier and hotter climate.

Fig. 4: Land use and climate niche determine colonization–extinction dynamics.
figure 4

a, Species-level annual persistence probability declines with increasing land-use intensity. be, The centres of the temperature niche (b, d) and precipitation niche (c, e) determine the probability that a population will persist or newly colonize a community across three land-cover types. Transparent points in a depict the modelled mean annual persistence probability for the three land-use types across Costa Rica for individual species, and shaded points depict the mean modelled response for each land-cover type across the 336 species tested, with 95% Bayesian credible intervals from a previously described multispecies dynamic occupancy model35. In b, c, points depict the modelled effect of climatic niche traits on the probability that a population will persist across years in the three land-cover types. In d, e, points depict the modelled effects of climate niche traits on the probability that a species newly colonizes a transect across the three different land-cover types. ae, nspp. = 336, ntransects = 44, nyears = 18.

Conclusions

Overall, our findings suggest that the effects of land-use change on long-term biodiversity dynamics develop across multiple temporal scales. It is well known that, at short time scales, the initial conversion rapidly reduces the species richness and alters composition and structure of the bird communities. Then, as we show here, time-lagged effects of habitat conversion more slowly restructure the communities by altering the colonization and extinction of species, driving long-term directional shifts in composition over decadal scales. In intensively managed landscapes, these long-term shifts are characterized by external forcing events through annual changes in vegetation and climate—especially during the hot, dry season.

Although current biodiversity models are able to predict the short-term consequences of land-use change on biodiversity8,36, our findings suggest that temporal lags—in combination with changes in vegetation and climate—complicate predictions regarding the state of biodiversity in intensively managed tropical agricultural landscapes that have been converted relatively recently. Notably, biodiversity changes in diversified-agricultural systems more closely mimic those found in natural forests.

Halting biodiversity loss in the twenty-first century will require moving away from a static view to one that incorporates the highly dynamic nature of ecological communities and the forces that are exerted on them. Halting loss also requires a paradigm shift to sustainable and resilient agricultural systems that promote not only farm productivity and livelihood security, but also biodiversity and nature’s full array of vital benefits to people1.

Methods

Study sites and bird censuses

We collected 18 years of bird survey data from 48 sites distributed across 4 distinct regions of Costa Rica that are separated by approximately 200 km. The study regions and crop types include: Las Cruces (premontane wet forest; coffee, cattle and mixed gardens), San Isidro (midelevation wet forest; coffee, pineapple and sugar cane), Puerto Viejo (lowland wet forest; heart of palm, banana and cattle) and Guanacaste (lowland dry forest; melon, rice and cattle). Within each region, transects were separated by an average of 10 km. Each transect was 200 m in length. Land-cover categories were determined using cluster analysis of landscape characteristics (that is, number of crop species, vegetation strata, quality and extent of hedgerows, size and number of agricultural plots, and forest cover at 100-m and 200-m radii; Supplementary Table 1) as previously described 10 and four sites were excluded from analyses owing to changes to crop types or management types during the course of the study (see ‘Land-cover classification and transect stability’).

All bird transect counts were conducted by expert ornithologist J.R.Z. Transect counts were conducted twice per year during the wet and dry seasons with three visits per season (nvisits/year = 6). For each transect, the three transect counts per season were conducted within a one-week time period to meet the assumption of community closure. Transect surveys began at sunrise each day and lasted for 30 min. For each count, J.R.Z. walked the 200-m transect while recording the identity and number of individuals for each species present on the basis of visual cues or sound. Only birds within 25 m to either side of transect lines were used in the present analyses; birds detected flying through or over a transect were excluded from analyses.

Assessing temporal trends

Ecological communities in each year are dependent on the composition in previous years and treating time as a standard covariate can result in pseudoreplication, because values in year t are dependent on the state of the system in t − 1. To deal with the temporal dependency structure of the diversity measures and to explicitly model long-term trends in the data, we applied a classical first-order random walk trend to our Bayesian generalized linear mixed-effects models. The random walk trend (μt) is modelled as the state in the previous year plus random noise (vt) described by a normal distribution, or μt = μt − 1 + vt in which \({v}_{t}\propto N(0,{\sigma }_{v}^{2})\). This approach allows us to separate out both the immediate effects of land-cover type on biodiversity patterns and to explore the different trends for each land-cover type.

We estimated an individual random walk trend for each land-cover type in addition to the fixed effects of land-cover type on diversity measures in each model. All analyses assessing temporal trends were conducted in a Bayesian framework using INLA in the R-INLA package37 for R38. Weakly informative penalized complexity priors for the parameters were used for all analyses in INLA39. Random walk trends were standardized around zero. Long-term directional trends were present when 95% Bayesian credible intervals around mean trend lines did not overlap zero at positive and negative values. We applied these methods to each aspect of diversity in turn.

Effect of land-cover type on long-term shifts in community composition

To address how agricultural intensification affects the long-term patterns of community change, we calculated directional shifts in community composition in each transect. Specifically, the temporal similarity of the community was calculated by comparing the multivariate distance between each community to itself in the first year of the study (2000) using the abundance-based Bray–Curtis similarity index. We then modelled the Bray–Curtis similarity index between each year using a Bayesian generalized linear mixed-effect model (GLMM) with a beta distribution with a logit link to account for the bounded nature of the data (in the range of 0–1). A random intercept for transect was included. Bayesian models were fit using INLA, and the posterior distribution was used to test for differences between land-cover types.

To determine whether using the first year of sampling (2000) biased our results, we additionally calculated long-term community shifts by analysing trends when using all pairwise temporal community comparisons for each transect. To do this, we first calculated the Bray–Curtis similarity index of all pairwise communities across all years for each transect. We then modelled the Bray–Curtis similarity index between all combinations of years using a Bayesian GLMM with a beta distribution with a logit link to account for the bounded nature of the data (in the range of 0–1). A random intercept for transect was included. Bayesian models were fit using INLA, and posterior distributions were used to test for differences between land-cover types. We found similar effects of land-cover type on long-term community shifts using this approach (Extended Data Fig. 8a–c and Supplementary Table 8), ensuring that using the year 2000 as the baseline did not bias our results.

We repeated these analyses using the presence–absence-based index (Jaccard similarity) and found qualitatively the same trends in compositional change (Exteneded Data Fig. 8d).

Effect of land-cover type on richness, abundance and rate of change in community similarity

Annual species richness was quantified as the Chao1-estimated species richness of bird communities during both the wet and dry seasons within each transect. To determine whether there were long-term changes in species richness during the course of this study, we modelled the effect of land-cover type on species richness using a Bayesian GLMM in INLA using the random walk trend approach described above. To account for overdispersion in the response data with a Poisson distribution, species richness was modelled using a negative binomial distribution with a log-link function, and individual transects were included as random intercepts. Because we found no trends in species richness, we used a maximum-likelihood approach to model the effects of land-cover type on average species richness across all years. The model was validated through checks of fitted versus residual values, residuals versus time and for overdispersion using Pearson residual values40. Differences between land-use types were determined using maximum-likelihood estimates Pr(>|z|). These analyses were conducted in R38 using the vegan41 and glmmTMB42 packages.

We next assessed whether there were long-term changes in total community abundance. Annual abundance for each transect was quantified as the average of total detections in the wet and dry seasons. Because mean transect counts were large and exhibited low dispersion, transect-level annual abundance was log-transformed43. Next, we used a Bayesian LMM with a Gaussian distribution, including a random walk component for each land-cover type in INLA and a random intercept for each transect. Model validation was checked by visually assessing the residual versus fitted values, observed versus fitted values, dependency structure in the covariates and normality in the response data40.

We used a multivariate distance-based approach to address how agricultural intensification alters the rate of change in community similarity between subsequent years. Specifically, the temporal change in community similarity for each transect was calculated by comparing the multivariate distance between each sampling point to the previous year using the abundance-based Bray–Curtis community similarity index. We then modelled the Bray–Curtis similarity index between each set of years using as a Bayesian GLMM. The Bray–Curtis similarity index was modelled using the beta distribution with a logit link to account for the bounded nature of the data (in the range of 0–1). A random intercept for transect was included. Temporal trends were assessed using the random walk methods described above. A Bayesian post hoc test of the posterior distributions was used to determine the differences in the rate of change in community similarity between land-cover types.

Habitat use by IUCN red-list, endemic and range-restricted species

We next assessed how IUCN red-list, endemic and range-restricted species used different land-cover types in each of the four study regions. To do this, we compiled information on the IUCN Red List status for each species44, as well as the endemic and range-restriction status for each of our sampled bird species45. Species listed as ‘endangered’, ‘near threatened’ or ‘vulnerable’, and endemic or range-restricted were used to assess habitat use by species that are a globally recognized conservation priority. We next used the occupancy of each of these species in each transect and modelled the effects of land-cover type on the number of red-list and endemic species using an analysis of variance (ANOVA). Differences between groups were assessed using Tukey post hoc tests.

We next assessed the temporal trends in the number of endemic or range-restricted and IUCN red-list species across each land-use type using a Bayesian LMM in INLA, containing a random-walk temporal-trend component for each land-cover type. Intensive agricultural transects in the Guanacaste and Puerto Viejo study regions all contained fewer than two species in each year (except for a single year in one transect in Puerto Viejo, which contained three). Analyses were limited to the Las Cruces and San Isidro study regions, as intensive agriculture communities contained too few IUCN red-list, endemic and range-restricted species to detect a trend. nspp. = 62, ntransects = 22, nyears = 18. Random walk trends were standardized around zero.

Estimates of conservation value should be seen as conservative, especially in comparison to forest communities. Analyses were limited to the 510 species that were observed during sampling periods, and some of the rarest and most-threatened species may have gone unobserved.

Effect of land-cover type on long-term trends in guilds

We next assessed how habitat conversion affects the temporal structure of individual feeding guilds. For the guild-level analysis, birds were identified as belonging to one of four primary feeding guilds: insectivores, frugivores, nectarivores and granivores, as previously described45. Scavengers and carnivores were excluded from all guild-level analyses, as they occurred in too few numbers when present in our transects. We next calculated long-term shifts in transect-level community similarity for each of the four guilds using the Bray–Curtis similarity index. Specifically, community similarity in each transect for each year was compared to itself for the first year of the study (2000). We modelled long-term shifts in community similarity for each guild using a Bayesian GLMM with a random walk component for each land-cover class using INLA. Transect-level community similarity values for each year were modelled as an effect of land-use type using a beta distribution, with transect treated as a random effect.

In addition to assessing the changes in community similarity, we modelled changes in the relative abundance of each guild in each land-cover type. Specifically, we calculated the relative proportion of each guild in each transect as a component of the entire community (excluding scavengers and carnivores). For each guild, we modelled the effects of land-cover type on shifts in relative abundance through time using a beta distribution in INLA.

Effect of land-cover type, LAI and climate on community shifts

Temporal patterns in temperature and vegetation were derived from MODIS remote-sensing data46. We computed three annual land surface temperature (LST) metrics and three LAI metrics with a 1-km2 grain size to track these patterns. For each year from 2002 to 2017, we aggregated all image scenes that covered our study region into an image collection and masked all cloudy pixels, as flagged by the MODIS QA algorithm. For both LST and LAI, we computed the annual pixelwise mean of all cloud-free measurements. The final outputs were the first statistical moment of both LST and LAI computed for each of the 16 years of overlap between the available field and MODIS data. We analysed MODIS data here, instead of higher-resolution data from—for example—Landsat, because Costa Rica is cloudy for most of the year47, and daily observations are required to sufficiently capture intra-annual temporal variation in temperature and vegetation patterns. As the focus of this analysis is on temporal variation, and less so on spatial variation, we made this scale-dependent decision on which data source to analyse48. All analyses were performed in Google Earth Engine49 using the MODIS MOD11A1.006 LST product50 and the MODIS MCD15A3H.006 LAI product51.

Temporal data on precipitation were obtained from Instituto Meteorológico Nacional de Costa Rica. Daily precipitation measurements from 2000 to 2014 were extracted from meteorological stations nearest to each regional study group. Dry-season length and intensity are expected to be important drivers of bird populations in tropical regions of the world52. However, because no standard measurements of dry-season length exist, we chose to instead focus on the distribution of daily rainfall in each year, measured as the skewness. We then calculated the skewness of daily precipitation in each region for each year.

We next modelled the interactive effects of temporal mean LST, mean LAI, precipitation skewness and land-cover type on bird community shifts using the Bayesian mixed-effect modelling approach with a random walk component as described above. An individual model was used for each of the three environmental covariates (mean LAI, mean LST and precipitation skewness). Because our focus is on how climatic and vegetative patterns interact with land use to drive temporal changes to bird communities, we chose not to include all three temporal covariates in a single model. This approach improved model performance and reduced the number of parameter estimates needed for each model. For mean LST and mean LAI, annual measurements were derived from 1-km2 grain-size data for each transect, whereas precipitation skewness is quantified from regional patterns. In addition, the data for LST and LAI were available for the 2002–2017 period, whereas the precipitation data coverage is from 2000 to 2014. To account for temporal differences in covariate coverage, calculations on changes in community composition were made using the entire dataset and subsequently using a subset to match the available data coverage of covariates in each model.

Land-cover classification and transect stability

Cluster analysis was used for land-cover classification in 1999 and 200210. At the beginning of each censusing season, J.R.Z. photographed all transects from several permanent fixed points within each transect in each year, making note of any changes to management and habitat characteristics. These photographs and notes were used to determine whether transects had undergone any substantial changes during the study that precluded them from analyses. In total, four transects underwent substantial changes in management that fundamentally restructured the system (for example, conversion from coffee to pineapple cultivation), and these transects were excluded from all analyses.

Crop diversity and plot size are two important determinants of bird diversity in agricultural systems because of their effects on spatial (vertical and horizontal) complexity. We next modelled the relationship of both crop diversity and average plot size with land-cover classification (diversified versus intensive agriculture) using ANOVA. This approach allowed us to test whether there are significant differences in these two variables across land-cover types. Both crop diversity (likelihood ratio test (LRT), P = 3.046 × 10−8) and average plot size (LRT, P = 0.0006875) differed by land-cover type. We next quantified the relationship between total community change across the 18 years (Bray–Curtis similarity index of communities in 2017 compared with 2000) and the crop diversity and average plot size measurements within a transect using linear models. We found a clear relationship between both crop diversity (LRT, P = 1.399 × 10−6) (Extended Data Fig. 7a) and average plot size (LRT, P = 4.441 × 10−5) (Extended Data Fig. 7b) with total community change in 2017. For all models in this section, model validation was checked by visually assessing residual versus fitted values, observed versus fitted values, dependency structure in the covariates and normality in the response data40.

Multispecies occupancy model

To understand how land use affects the colonization and extinction of species, we used a Bayesian multispecies dynamic occupancy model that accounts for imperfect detection35,53. We modelled the effect of land use on the annual persistence probability and annual colonization probability as a linear response to standardized climate niche variables related to temperature and precipitation throughout the breeding range of a species, and included region, site and species-level random effects. The detection probability varied for each species and land-use combination, and included site, species and year as random effects. Using this approach, we modelled wet-season community dynamics, although dry-season dynamics were highly correlated and showed similar qualitivate results35. We only included the 336 species with more than 25 counts over the 18 years to improve model performance and parameter estimates.

The model was analysed in JAGS using vague priors. We ran the model with 3 chains, each with 15,000 iterations. The first 3,000 iterations were discarded as burn-in, and the remaining chains were thinned at a rate of 30, for a total of 1,200 posterior samples. Model convergence was evaluated by visually examining traceplots for each parameter and ensuring that \(\hat{R} < 1.1\).

Accounting for multiple landscape features in diversified agriculture

We used two analyses to address how the inclusion of complex landscape features and natural elements within diversified agricultral transects affected our findings. First, we calculated an empirically derived estimate of habitat affinity for each species in each land-cover type. To do this, we first created a transect-by-species matrix using the scaled sum of each species abundance in a transect across all years. We used these values as a rough proxy for habitat affinity, with negative values indicating low affinity, and positive values indicating high affinity. Because this approach is weighted by abundance, forest species that may only use forest elements within a diversified agricultural transect, but do not enter the agricultural plot or occur in large number will be given a low (negative) habitat affinity score. This approach was restrictive, and when applied maintained species that are primarily agricultural specialists, reducing the diversified agriculture species pool from 376 to 199 species.

Second, we used the data that we collected on microhabitat use by each individual that was counted in surveys in agricultural transects. Using these data, we removed all individuals found within natural landscape elements (that is, trees) or directly adjacent to forest patches (for example, individuals using the forest–agricultural interface). By excluding individuals that were directly adjacent to forest patches, we ensured that we were not capturing temporary spillovers from forest patches into agriculture.

Using these measures of habitat affinity and microhabitat use, we found little effect of removing species with low habitat affinity to diversified agriculture on temporal changes in community composition (Extended Data Fig. 9a). We also found that removing species with low habitat affinity decreased species richness (Extended Data Fig. 9b). There was little effect of removing individuals found in trees, suggesting that most species found using trees in diversified agriculture were also found using agricultural components of the habitat, in addition to more-natural landscape elements (Extended Data Fig. 9).

Reporting summary

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