DOI: 10.6084/m9.figshare.28785908
title: <b><i>LTMP analysis 11-year versus 25-year with missing data</i></b>

description: This repository contains all the scripts and data used in the analysis of the LTMP data presented in the manuscript <i>“Longer time series with missing data improve parameter estimation in State-Space mode in coral reef fish communities”</i>. There are 22 files in total.All model fits were run on the HPC cluster at James Cook University. The model fit to the 11-year time series took approximately 3-5 days and the model fit to the 25-year time series took approximately 10-12 days. We did not include the model fits as they are big files (~12-30GB) but these can be obtained by running the corresponding scripts.<b>LTMP data and data wrangling</b><b>LTMP_data_1995_2005_prop_zero_40sp.RData: </b>File containing 45 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 third column called <i>Reef_lat</i> and fourth 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 40 species with the lowest proportion of zeros in the LTMP data. This contains data from 1995 to 2005.<b>LTMP_data_1995_2019_prop_zero_40sp.RData: </b>Same data structure as above but for the time series from 1995 to 2019 (includes Nas in some of the abundance counts).<b>dw_11y_Pomacentrids.R</b> and <b>dw_25yNA_Pomacentrids.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_40sp_Pomacentrids.RData</b> and <b>LTMP_data_1995_2019_prop_zero_40sp_PomacentridsNA.RData</b>.<b>Model fitting</b><b>LTMP_fit_40sp.R </b>is a script that fits the model to the 11-year time series data. Specifically, the input dataset is <b>LTMP_data_1995_2005_prop_zero_40sp_Pomacentrids.RData</b> and the output fit is called <b>LTMP_fit_40sp.RData</b>.<b>LTMP_fit_40sp_NA.R </b>is a script that fits the model to the 25-year time series with missing data. Specifically, the input dataset is <b>LTMP_data_1995_2019_prop_zero_40sp_PomacentridsNA.RData</b> and the output fit is called <b>LTMP_fit_40sp_NA.RData</b>.<b>Stan model</b><b>MARPLN_LV_Pomacentrids.stan</b>: Stan code for the multivariate autoregressive Poisson-Lognormal model with the latent variables.<b>MARPLN_LV_Pomacentrids_NA.stan</b>: Stan code for same model as above, but this can deal with missing data.<b>Figures</b><b>Figure 1 A and B.R</b> and <b>Figure 4.R</b> produce the corresponding figures in the main text.Note that <b>Figure 1A and B.R</b> requires several files to produce the GBR and Australia maps. These are:<b>Great_Barrier_Reef_Features.cpg</b><b>Great_Barrier_Reef_Features.dbf</b><b>Great_Barrier_Reef_Features.lyr</b><b>Great_Barrier_Reef_Features.shp.xml</b><b>Reef_lat_long.csv</b><b>Great_Barrier_Reef_Features.prj</b><b>Great_Barrier_Reef_Features.sbn</b><b>Great_Barrier_Reef_Features.sbx</b><b>Great_Barrier_Reef_Features.shp</b><b>Great_Barrier_Reef_Features.shx</b>