The ZIP file Code.zip contains the example code for fitting the unified model to a species x sites abundance matrix (formatted in the same way as the CSV files in Abunds.zip), conducting parametric bootstrap goodness of fit testing, estimating metacommunity species pool size, and conducting the out-of-sample prediction test. There are 5 files: FitUnifiedModel.R: Reads in a CSV file of count data, and fits the unified model, as well as the alternative model where there is a gamma metacommunity species-abundance distribution instead of a lognormal SAD. This script includes estimation of metacommunity species pool richness. GOFtest_UnifiedModel.R: Conducts parametric bootstrapping of the unified model for the data analyzed and the fitted model produced by FitUnifiedModel.R OutOfSamplePrediction_UnifiedModel.R: Calculates the predicted number of species for the out-of-sample prediction test shown in Fig. 4. Specifically, for each site in the metacommunity CSV file, it fits the unified model to all of the other sites, and predicts the number of species that are observed in at least one of the fitted sites that would NOT be observed at the site that has been excluded from the fitting. NBLNPL_LLfxn.R: Functions needed to calculate the log-likelihood for the unified model. NBGPL_LLfxn.R: Functions needed to calculate the log-likelihood for the alternative model with a gamma metacommunity species-abundance distribution.