DOI: 10.6084/m9.figshare.24961575.v1
title: LTMP data and scripts for analysis

description: This repository contains the data, the R and Stan scripts used to implement the analyses in the manuscript “<i>High response diversity and conspecific density-dependence, not species interactions, drive dynamics of coral reef fish communities</i>”. There are 27 files in total. We did not include the model fits as they are big files (~15-17GB). We ran the model fits on the HPC at James Cook University.<b>LTMP data and data wrangling</b><b>LTMP_data_1995_2005_prop_zero_20sp.RData: </b>File containing 25 columns. The first column is <i>Year</i> and it contains the year for each observation in the dataset. The second column <i>Reef</i> contains the reef name, while the latitude and longitude are collected in the 3<sup>rd</sup> column called <i>Reef_lat</i> and 4<sup>th</sup> column called <i>Reef_long</i>, respectively. The fifth column is called <i>Shelf</i> and contains the reef shelf position as I for Inner shelf positioning, M for Middle Shelf positioning and O for outer Shelf positioning. The rest of the columns contain the counts of the 20 species with the lowest proportion of zeros in the LTMP data.<b>LTMP_data_1995_2005_prop_zero_40sp.Rdata: </b>File containing 45 columns. The data structure is the same as the file above, but this includes the abundances for the 40 species with the lowest proportion of zeros in the LTMP data.<b>dw_Pomacentrids_20sp.R</b> and <b>dw_Pomacentrids_40sp.R</b> scripts order species in pomacentrids and non-pomacentrids so the models can be fitted to the data. These files produce the data files <b>LTMP_data_1995_2005_prop_zero_20sp_Pomacentrids.Rdata </b>and <b>LTMP_data_1995_2005_prop_zero_40sp_Pomacentrids.Rdata</b><b>Model fitting</b><b>LTMP_fit_40sp_D2.R</b>, <b>LTMP_fit_40sp_D4.R</b>, <b>LTMP_fit_40sp_D6.R</b>, <b>LTMP_fit_40sp_D8.R</b>, <b>LTMP_fit_40sp_D10.R</b> and <b>LTMP_fit_40sp_D12.R</b> are scripts that fit the models with 2, 4, 6, 8, 10 and 12 latent variables to the LTMP dataset with 40 species.<b>LTMP_fit_20sp.R</b> is a script that fits the model (2 latent variables) to the LTMP dataset with 20 species.<b>LTMP_fit_20sp_randReef_prior.R</b> is a script that fits the model (2 latent variables) to the LTMP dataset with 20 species and also includes random effects at the reef level.<b>Cross-validation</b><b>poilog_D2.R, poilog_D4.R, poilog_D6.R, poilog_D8.R, poilog_D10.R </b>and<b> poilog_D12.R</b> estimate the likelihood for the model fit with 2, 4, 6, 8, 10 and 12 latent variables, respectively.<b>Model_comparison_TableS2: </b>Produces the Table S2 in the appendix, which shows the model comparison based on the ELPD.<b>Stan models</b><b>MARPLN_RHS_LV_Pomacentrids.stan: </b>Stan script for the multivariate autoregressive Poisson-Lognormal model with the regularised horseshoe prior and latent variables fitted to the LTMP data.<b>MARPLN_RHS_LV_NonPomacentrids_Rrand_prior.stan: </b>Stan script for the multivariate autoregressive Poisson-Lognormal model with the regularised horseshoe prior and latent variables. This model was fitted to non-pomacentrid species, and it included reef random effects for the intrinsic growth rates and the intraspecific density dependence. It also has tighter priors to ensure convergence.<b>Figures</b><b>Figure 3.R, Figure 4.R,</b> <b>Figure 5.R</b> and <b>Figure 6.R </b>produce the corresponding figures in the main text of the manuscript.<br>