Supplement 1. R code and fynbos data set.

<h2>File List</h2><blockquote> <p> <a href="Merow_et_al_R_code.r">Merow_et_al_R_code.r</a> -- R code for all analyses </p> <p> <a href="fynbos_abundance_matrix.csv">fynbos_abundance_matrix.csv</a> -- matrix of relative abundance (rows) by sites (columns) </p> <p> <a href="fynbos_trait_matrix.csv">fynbos_trait_matrix.csv</a> -- matrix of species (rows) by traits (columns) </p> </blockquote><h2>Description</h2><blockquote> <p> The file Merow_et_al_R_code.r contains R code for constructing the EM models shown in the main text. This includes the basic EM model, calculating the Hellinger fit metric, Lagrange multipliers and plotting results for both local and regional communities. We also include code for predicting community-aggregated traits from splines, cross validation, generating informative priors and permutation tests. The file fynbos_abundance_matrix.csv contains site by site relative abundance data for the eight elevational communities we used (derived from 43 5 × 10 m releves) from the Baviaanskloof Mountains, South Africa. The file fynbos_trait_matrix.csv contains data for each species on the following traits: graminoid (binary), succulent (binary), maximum height, leaf longevity (ordinal 1–3, 1 is lowest), flowering duration, pubescence (binary), leaf width, leaf perimeter^2/leaf area, leaf area/basal diameter, stem length/stem basal diameter^(2/3). These traits have been rescaled to lie on the interval [0,1]. </p> <p> Checksum values are as follows: </p> <p> For fynbos_trait_matrix.csv the columns sum to: col 1 (life.form.graminoid) = 19, col 2 = 2, col. 3 = 5.84708, col. 4 = 24, col. 5 = 18.09093, col. 6 = 14, col. 7 = 7.75024, col. 8 = 8.16681, col. 9 = 6.7815, and last col. = 8.2096. </p> <p> For fynbos_abundance_matrix.csv, all columns sum to 1. </p> </blockquote>