DOI: 10.5061/dryad.q83bk3jpp
title: R codes from: Breakdown of the growth–mortality trade-off along a soil phosphorus gradient in diverse neotropical forest

description: An ecological paradigm predicts that plant species adapted to low resource
 availability grow slower and live longer than those adapted to high
 resource availability when growing together. We tested this by using
 hierarchical Bayesian analysis to quantify variations in growth and
 mortality of ~ 40,000 individual trees from &gt; 400 species in
 response to limiting resources in the tropical forests of Panama. In
 contrast to theoretical expectations of the growth–mortality paradigm, we
 find that tropical tree species restricted to low-phosphorus soils
 simultaneously achieve faster growth rates and lower mortality rates than
 species restricted to high-phosphorus soils. This result demonstrates that
 adaptation to phosphorus limitation in diverse plant communities modifies
 the growth–mortality trade-off, with important implications for
 understanding long-term ecosystem dynamics.
description: The codes were created to examine species-specfic growth and
 mortality responses to environmental factors (e.g., water stress and soil
 chemical properties) with the data from long-term vegetation
 dynamics. 
description: The code requires to install R software, associated packages
 ("parallel", "rjags", runjags", and
 "compute.es"), and JAGS to open and run. 
description: This is supplementary data for the paper entitled “Breakdown of the
 growth–mortality trade-off along a soil phosphorus gradient in diverse
 neotropical forest”. The files hold (i) the R codes for growth and
 mortality analyses using data of long-term vegetation dynamics
 (hierarchical Bayesian analysis), (ii) example dataset, and (iii) the
 specie-specific estimation of beta values (species-specific responses to
 size or environmental factors; see the original article for more
 information). In this article, we applied the R code to the data of
 plot-network in Panama (Condit et al. 2019; Turner & Condit 2022).
   Condit, R., Pérez, R., Aguilar, S. & Lao, S. (2019). Census data
 from 65 tree plots in Panama, 1994-2015. *Dryad, Dataset* Turner, B.L.
 & Condit, R. (2022). Soil chemistry and dry season intensity,
 Panama Canal Area. *Dryad, Dataset*     #1. R
 codes###################################### The R codes define the
 “genMCMC” function to estimate species-specific relationship of growth or
 mortality with size and environmental factors based on data of long-term
 vegetation dynamics, and the effects of species environmental association
 (distribution in relation to soil P, shade, and moisture gradients) on
 growth or mortality responses to size and environmental factors.   genMCMC
 = function(data, data\_association, xName, yName, sName, AName, Period,
                     numSavedSteps = 10000, thinSteps = 10, saveName =
 NULL,                     runjagsMethod = runjagsMethodDefault,
                     nChains = nChainsDefault) {…}   The function requires
 several data as follows. 1. data: This is a dataframe including columns of
 y values (e.g., growth or status) and x values (e.g., size and
 environmental factors) with species name and census intervals (only for
 mortality analysis) at the first level of the Bayesian model. See
 “ExampleDataForMortalityAnalysis.csv” for an example dataset. 2.
 data\_association: This is a dataframe including columns of species name
 and its environmental associations (e.g., P associations), which are used
 at the second level of the Bayesian model. See
 “ExampleDataAssociationForMortalityAnalysis.csv” for an example dataset.
 3. runjagsMethod and nChains: These data will be defined automatically by
 the R code. 4. saveName: The name of the file including the result of
 MCMC. “filename.csv” 5. Also, the function requires to specify the column
 names in the dataframe (data). Examples. yName = "growth rate"
 or “status” (1, alive; 0, dead) xName =
 c("ShadingIndex","dbh", "Resin.P",
 "Water deficit"); sName = "Species" AName =
 c("Phosphorus\_association",
 "Shade\_association","Moisture\_association",
 "PS", "PM", "SM", "PSM") Period =
 “Period” (census intervals in year)   #2. Example data set
 ###################################### Two csv files include
 “ExampleDataForMortalityAnalysis.csv” and
 “ExampleDataAssociationForMortalityAnalysis.csv”.   Columns in
 “ExampleDataForMortalityAnalysis.csv” DataID: IDs for each individual.
 Status: Individual status at the second census (after the census
 interval); 1, alive; 0, dead. Deficit: The dry season moisture deficit,
 which represents the intensity of the dry season (between December and
 April) as the minimum annual value of cumulative daily precipitation minus
 evapotranspiration, varied from –392 to –580 mm. A more negative moisture
 deficit indicates a longer, drier, dry season. Resin.P: Concentrations of
 readily available phosphorus (mg kg<sup>–1</sup>), which was
 determined by extraction with anion-exchange membranes (*i.e.,* resin
 phosphate). ShadingIndex: Index for light availability, which was
 calculated as the sum of the distance-weighted basal areas of trees larger
 than and within 10 m of each focal tree. Dbh: Diameter at breast height
 (mm). Species: Species code. See Condit et al. 2019 and Turner and Condit
 2022 for the more information. Period: Census intervals (year). Plot: Plot
 name.   Columns in “ExampleDataAssociationForMortalityAnalysis.csv”
 DataID: IDs for each species. Species: Species code. See Condit et al.
 2019 and Turner and Condit 2022 for the more information.
 Phosphorus\_association: Species-specific environmental  association in
 relation to soil phosphorus. Shade\_association: Species-specific
 environmental  association in relation to shade. Moisture\_association:
 Species-specific environmental  association in relation to moisture
 availability. PS: Interaction between phosphorus association × shade
 association PM: Interaction between phosphorus association × moisture
 association SM: Interaction between shade association × moisture
 association PSM: Interaction between phosphorus association × shade
 association× moisture association   #3. Specie-specific estimation of beta
 values ###################################### The csv files include the
 information on species characteristics and the estimation of beta values.
 See original article for more information.   Species: Species code. See
 Condit et al. 2019 and Turner and Condit 2022 for the more information.
 Phosphorus\_association: Species-specific environmental  association in
 relation to soil phosphorus. Shade\_association: Species-specific
 environmental  association in relation to shade. Moisture\_association:
 Species-specific environmental  association in relation to moisture
 availability. beta0\_median: Species-specific estimation of intrinsic
 growth or mortality rate. beta1\_median: Species-specific estimation of
 growth or mortality responses to shade. beta2\_median: Species-specific
 estimation of growth or mortality responses to size. beta3\_median:
 Species-specific estimation of growth or mortality responses to soil
 phosphorus availability beta4\_median: Species-specific estimation of
 growth or mortality responses to moisture availability