Early warning of critical transitions in biodiversity from compositional disorder

Abstract Global environmental change presents a clear need for improved leading indicators of critical transitions, especially those that can be generated from compositional data and that work in empirical cases. Ecological theory of community dynamics under environmental forcing predicts an early replacement of slowly replicating and weakly competitive “canary” species by slowly replicating but strongly competitive “keystone” species. Further forcing leads to the eventual collapse of the keystone species as they are replaced by weakly competitive but fast‐replicating “weedy” species in a critical transition to a significantly different state. We identify a diagnostic signal of these changes in the coefficients of a correlation between compositional disorder and biodiversity. Compositional disorder measures unpredictability in the composition of a community, while biodiversity measures the amount of species in the community. In a stochastic simulation, sequential correlations over time switch from positive to negative as keystones prevail over canaries, and back to positive with domination of weedy species. The model finds support in empirical tests on multi‐decadal time series of fossil diatom and chironomid communities from lakes in China. The characteristic switch from positive to negative correlation coefficients occurs for both communities up to three decades preceding a critical transition to a sustained alternate state. This signal is robust to unequal time increments that beset the identification of early‐warning signals from other metrics.


Description
The simulation results presented in the main text and Appendix S1 was produced with the code "Ecosystem Simulation Version 2". The entire source code is available for download in DataS1.zip. The archive consists of 29 individual Matlab function files, a parameter setting asv file, a text-file short manual, and a PDF user manual.
The individual Matlab function files are called from Repeat_simulation.m which serves as a wrapper for all functions and is the file that is executed in order to produce simulation results.

Repeat_simulation.m
The script Reapeat_simulation allows the simulation to be run with the same community (alpha and c, imported or created at the beginning of the session) or different community (alpha matrix and c created for every simulation).
The source code for this script contains extensive comments.
The vectors "mode" contains on every row the parameters for one set of simulations, and the vector "value" contains all values of these parameters.
--PARAMETERS --K -size of the environment (~1000) D -type of degradation (0:none, 1:1 fluctuating phase,2: fluctuation around ddef then fluctuation and global increase,3: linear increase and decrease) d -default value of death rate (~0.1) c -minimum value of intrinsic growth rate (~0.1>d) n -number of starting species (<K/30) i -invasion flux, 0: constant, 1: fluctuating t -number of time-steps (~1000) s -type of trade-off, 'linear' or 'sigmoidal' (default) b -slope of sigmoidal trade-off (~-16) P -randomness of competition (0<P<1) f -detection threshold (~5) It is possible to define alternative settings by modifying the default value of all variables (not only variables listed hereabove) in the function "ecosystem_a". For example changing the total number of species N need to change the value of N in the function "ecosystem_a" (in this case, be sure that the number of species defined in alpha and c are consistent if you use the same community for all simulations).
-LOAD ALPHA AND C --In order to load custom ALPHA and C, two separate files are required. Enter the name (or path and name) of these files when the script ask you to do so. Note: the Number of species defined in alpha and c, has to be consistent with the value of N in the function "ecosystem_a" --USE THE SAME ALPHA AND C It is possible to use the same alpha and c for all simulations, in this case you have the possibility to save these variables at the end of session. You can change the number of species is the community, and the value of beta for the trade-off in the script Repeat_simulation.
--SAVING AND DISPLAY OPTION -Option specific from "ecosystem_a" saving and displaying have to be mofied directly in the code of the function.