################################################################################# This is the README file for: Appendix S3: Description of the data structures and sample code Mihaljevic et al. (in revision, J. Animal Ecology) ################################################################################# This directory contains a number of R scripts and R data object files (.RData). We will describe each below, although each has been commented extensively as well. These we divide into categories for ease. ################################################################################# 1. Scripts and data for running statistical model in JAGS. NOTES: We have provided input and output data (Supp_Data_SpatHabHost.RData) for our multi-species occupancy model for the full covariate model, "SpatHabHost". As the name implies, this model includes covariate effects related to all of our three categories: spatial components, habitat filtering, and host community composition. The model is run twice, in order to calculate the out-of-sample predictive measure, ROC AUC. The relevant input data can be found as objects: Y.obs: Symbiont occurrence in 2009-2012 Y.obs_2013: Symbiont occurrence in 2013 X: Scaled covariate measures for sites in 2009-2012 X_2013: Scaled covariate measures for sites in 2013 J: Number of frogs sampled per wetland in 2009-2012 J_2013: Number of frogs sampled per wetland in 2013 (Note that covariate scaling was done across 2009-2013, using the among year mean and standard deviation for each covariate) These data are restructured in object "jags_d" to fit the model formulation, as described in the main text. File Descriptions: - "2013_SpatHabHost.R": code that runs the model for 2013 data only. Model output is stored in "mcmc_2013_SpatHabHost" - "AllYears_SpatHabHost.R": code that runs the model for 2009-2013 data. Note that we use NA values for 2013 occurrence data in order to predict the 2013 occurrence probabilities from 2013 covariate measures. These predictions are used for the ROC AUC measure. Model output is stored in "mcmc_2013_SpatHabHost" - "Chains_Process_2013.R”: code to observe MCMC chain dynamics for the 2013-only model run. - "Chains_Process.R”: code to observe MCMC chain dynamics for the 2009-2013 model run. Additionally, calculation of ROC AUC and WAIC. - "OccMod_AUC.R": code (R function) to calculate the species-wise and overall ROC AUC from a given model run. - "calc_waic.R": code (R function) to calculate the species-wise, year-wise, and overall WAIC for a given model run. - "MLMmodel_2013_SpatHabHost.txt": JAGS model statement for 2013-only model run - "MLMmodel_SpatHabHost.txt": JAGS model statement for 2009-2013 model run. ################################################################################# 2. Scripts and data to create a table of 95% high density intervals for covariate effects File Descriptions: - "HDI_betas.RData": summary data from our 8 models, included as R lists. - "Betas_Table.R": example code to create our Table 4 (covariate effects) from the SpatHabHost model. ################################################################################# 3. Scripts and data for estimating and displaying metacommunity structure from the statistical model output. File Descriptions: - "Structures_ALL.RData": output data from our 8 statistical models. - "Z_list_yearly" contains the site x species arrays (Z_post) for each year, for each statstical model. These are used to calculate the posterior metacommunity statistics. - "Metacom_stats_yearly" contains the estimated metacommunity statistics (coherence, turnover, boundary clumping) derived from the "Z_list_yearly" object. - "Structure_yearly" contains the nominal metacommunity structure derived from the previous two objects. - "Metacom_Structure_Yearly.R”: example code detailing how the metacommunity structure metrics were derived for each model. Note that this script is not ready-to-run, so that we could detail how this was done for all of our statistical models. However, it could be easily adapted to run specifically for the "SpatHabHost" model output, which is provided (see section 1 above). - "Structure_Table.R": code for generating Table 5 from the main text. - "Structure_Name.R": code (R function) that determines the nominal metacommunity structure, based on the calculated metacommunity statistics. - "Matrix_HeatMap_NMDS().R": code (R function) for displaying the ordinated metacommunity structures (site x species arrays)