Supplement 1. Code for simulations and statistical models.

File List

Menge_Latitudinal_Abundance_Model_Code.R (MD5: 7917640d0c7cf0c449b97517fa29133d)

Menge_SuccessionDynamicsModel_Script.m (MD5: e3bb898eef5b2e1d104cc90629d37120)

Menge_SuccessionDynamicsModel_Pars.m (MD5: 4f3456b66d123b4a957d5a21e74951d8)

Menge_SuccessionDynamicsModel_odes_ob_non.m (MD5: c32d1000d5a3c7047a5ed86d479e97ab)

Menge_SuccessionDynamicsModel_odes_fac_non.m (MD5: 401ad7cdb1a9d6d6785964231f133e82)

Menge_SuccessionDynamicsModel_Figures.m (MD5: e1e7346752dd3e7b8b6e9a101066a5a5)

Menge_SuccessionDynamicsModel_FigB8_Script.m (MD5: 9a482ad728fb63538bde2965c79a6041)

Menge_SuccessionDynamicsModel_Pars_3.m (MD5: 1ce6191d5cfc70061fd037ae6df80905)

Menge_SuccessionDynamicsModel_odes_fac_ob_non.m (MD5: 7c1ba58eb3e7563bad78d2301d2a1da0)

Menge_SuccessionDynamicsModel_swa.m (MD5: 2f0631669f3411753e287a264bd1ebd7)

Menge_SuccessionDynamicsModel_FigB8_Figure.m (MD5: 9e4a1d2b02675b6c52f64e1e39f76bd5)


This supplement contains files that consist of code for simulations and statistical analyses consisting of 1 .R (R) file for the "Latitudinal Abundance Model" and 10 .m (matlab) files for the "Succession Dynamics Model."

The .R file, Menge_Latitudinal_Abundance_Model_Code.R, contains the statistical model code. It creates a dataframe with latitude and the 1-degree-latitude mean percent basal area occupied by N fixers (the data used in model fitting). It then creates variables for the abundance of each type in each habitat for given age distribution; these data were output from the Successional Dynamics Model and weighted by different age distributions. It then creates some functions needed for the model fitting exercise (as described in the text), and uses nls to fit the model to the data. Finally, it plots up the results. As currently set up, it creates Fig. 4 in the paper. To create Fig. B4–B7, some of the variables must be changed and the code rerun, as indicated in the code comments.

The Successional Dynamics Model code is contained in the .m files. There are 5 .m files associated with running the simulation for Fig. 3. Menge_SuccessionDynamicsModel_Script.m is the main script. It calls Menge_SuccessionDynamicsModel_Pars.m to set the parameters, sets up the initial conditions for each simulation, runs the simulation(s), saves the data, and calls the script that makes the figure. Options in the file (used to create the different panels) are changing SevModNon and whichrun (as indicated in the code). The files Menge_SuccessionDynamicsModel_odes_ob_non.m and Menge_SuccessionDynamicsModel_odes_fac_non.m are the functions that describe the mathematical equations of the model, and are called in the main script with the function ode45. The file Menge_SuccessionDynamicsModel_Figures.m sets up the figure, loads the data for each panel (which must be made, first, from the main script), then fills out each panel.

There are 5 .m files associated with running the simulation for Appendix B Fig. B8. The file Menge_SuccessionDynamicsModel_FigB8_Script.m is the main script. It initializes the parameter values for all three types (in the file Menge_SuccessionDynamicsModel_Pars_3.m), loops over habitat types and cost values (expressed as "psi," which is related to gamma in the paper by gamma = psi * c, with c = 120 per year), then numerically integrates the model Menge_SuccessionDynamicsModel_odes_fac_ob_non.m with the matlab function ode45, then weights the successional abundances by the FIA age distribution using the function Menge_SuccessionDynamicsModel_swa.m (also does so for the alternate age distributions, but these are not used in the figure), saves the data, then calls the figure script. The file Menge_SuccessionDynamicsModel_FigB8_Figure.m sets up the figure, loads the data, and fills out the panels. Editing of axis and panel labels directly on the pdf was done in Adobe Illustrator. Note that this run takes a long time.