R Code

Disclaimer: The R scripts and functions posted here are free for you to download and use (under the terms of GNU GPL v2). The code offered is unsupported- I make no claims that they will work with your data or increase your general well being- but I am happy to answer questions. Please consider citing the related papers if you use them, modify them in your own research, or figure out how to solve a problem by looking at them.

Community assembly simulations

Basic models of community assembly. Used to generate simulated communities of a specified size from a larger species pool under models of trait-based competition, habitat filtering, and random assembly. From Kraft and Ackerly 2010, Ecological Monographs and Kraft et al. 2007 American Naturalist.

Code

Trait-based tests of community assembly

Null model analyses to test if species in a community are a random subset of potential colonists from a larger species pool with respect to a single continuous trait. Tests trait mean, range, variance, kurtosis, and three metrics of even spacing (SDNN, SDNNr, SDNDr). Compares the rank of the observed community to the null distribution (can be used to calculate a p-value), and calculates a standard effect size. Random draws can be weighted by a species abundance or occurance freuquency. For more details and definitions of metrics see Kraft and Ackerly 2010, Ecological Monographs and Kraft et al. 2008 Science.

Code

Hierarchical Bayesian model of a trait-demography relationship

Sample code of a hierarchical bayesian model describing the relationship between a trait (wood density) and a demographic parameter (mortality rate). From Kraft, Metz, Condit and Chave, in press, New Phytologist. A sample dataset is available from the New Phytologist website.

Code

Measuring community dissimilarity (beta-diversity) while accounting for local variation in richness (alpha-diversity)

Function to calculate the Raup-Crick null-model based measure of beta-diversity and variants. From Chase, Kraft, Smith, Vellend and Innouye, 2011, Ecosphere.

Code