DOI: 10.5061/dryad.brv15dvjw
title: Code and data from: Survey-based inference of continental African elephant decline

description: Long-term quantification of temporal species trends is
 fundamental to the assignment of conservation status, which in turn is
 critical for planning and targeting management interventions. However,
 monitoring effort and methodologies can change over the assessment period,
 resulting in heterogeneous data that are difficult to interpret. Here, we
 develop a hierarchical, random effects Bayesian model to estimate site
 level trends in density of African elephants from geographically
 disparate survey data. The approach treats the density trend per site as a
 random effect and estimates a parametric distribution of these trends for
 each partitioning of the data. Data were available from 475 sites, in 37
 countries, between 1964 and 2016 (a total of 1,325 surveys). We
 implemented the model separately and in combination for the African forest
 (Loxodonta cyclotis) and savannah (Loxodonta africana) elephant species,
 as well as by region. Inference from these distributions indicates a mean
 site-level decline for each species over the study period, with the
 average forest elephant decline estimated to be more than 90% compared to
 70% for the savannah elephant. In combination, there has been a mean 77%
 decline across all sites; but in all models, substantial heterogeneity in
 trends was found, with stable to increasing trends more common in southern
 Africa. This work provides the most comprehensive assessment undertaken on
 the two African elephant species, illustrating the variability in their
 status across populations. 
description: This submission contains the code for the analysis of the survey
 data, which are included in the submission. Due to differences in
 resources for monitoring across sites and the development of new
 techniques over decades of data collection, surveys varied widely with
 respect to method, effort, and frequency. More specifically, the
 methodology and temporal range of data differed between sites; and at any
 one site, surveys may have used different methods, with different
 associated levels of observation error, and with different survey area
 sizes that may or may not have included the complete elephant population.
 We further lacked information on intrinsic demographic rates of growth or
 carrying capacity, which change across the continent due to environmental
 conditions. These limited and inconsistent data constrained our analytical
 approach in three important ways. First, we modeled elephant density
 rather than numbers since the survey area size was not constant over time
 for most survey sites. Second, we were able to fit only the simplest
 exponential population model: A logistic model of density-dependent growth
 did not converge. Third, we lacked overlapping, comparative data across
 sites that would allow us to calculate an overall measure of population
 change directly from estimated site-specific trends. 
description: # Code for analysis of data in 'Survey-based inference of continental
 African elephant decline'
 [https://doi.org/10.5061/dryad.brv15dvjw](https://doi.org/10.5061/dryad.brv15dvjw) Survey-based inference of continental African elephant decline Code and scripts for model release. `R` code is supplied for running the `constant` and `linear` trend models with the `global`, `species` and `regional` partitions. To execute each model using `R (&gt;=4.4.1)` and `rstan (&gt;=2.32.6)` simply run the `run_regression.R` script within the appropriate directory. Please contact the authors if any assistance is required. ### Files and variables Two data files are included: "DataFileElephantTrends" and "survey_area" The first file "DataFile_ElephantTrends" contains 6 columns of data. The names of sites for which survey data are available of African elephant numbers are in the column labeled "site" - note these sites names have been anonymized to comply with IUCN rules regarding place names harboring a species with a Red List status of endangered. The year during which a survey at a given site was conducted is listed in the "year" column. The estimated abundance of elephants in that site during that year of the survey is listed under the column labeled "surveycount". Note the numbers in this column are estimated numbers of elephants. In addition to these data, three columns represent different partitions of the data used for different analyses that were run in the manuscript. This includes "partition global", "partition species", "partition region", where global groups all sites and surveys into a single category representing all elephants in Africa, species separates sites based on whether they harbor forest elephants (Africana cyclotis) or savannah elephants (African loxodonta), and region separates sites into the four regions of Africa commonly used to discuss elephant conservation status (Forest, East, South, North). The second file  "surveyarea" includes three columns labeled site, year, survey_area. The site column contains a list of anonymized site names. The year column contains the year for the corresponding area of that site, where every site has areas for each year between 1963-2016. And the survey_area column contains the area in square kilometers that was surveyed for that site in that year. Because survey areas changed over years between surveys, the survey area list for sites in years between when surveys occurred were linearly interpolated. As such, some sites show a linear change in survey area over time. ### SOFTWARE: code is organized into 4 folders related to each of the analyses conducted in the manuscript: stan; by_region; by_species; global The stan folder contains the code for the constant and linear model as described in the manuscript. Given the correct version of R and Stan are loaded for a user, this code can be easily implemented to get the models to run as conducted in the manuscript. For either model, model inputs required to implement the models are the following (specified in the partition specific input file): P: number of partitions; N: number of records; S: number of sites per partition; Y: number of years Vector data sets are also required, including: XY: year; XS: survey site And finally the survey data to be analyzed which includes the numbers of elephants derived from each survey: y: survey numbers Each partition of the data (by_region; by_species; global) is listed in a separate folder containing 4 files: inits_constant; inits_linear; inputs; run_regression The inits_constant and inits_linear files contain the model prior parameter values* *x0_log, alphaP, alphaS, tauS, gamma, and phi The inputs file contains the raw survey data as well as the model inputs required to run the model code. To execute each model using `R (&gt;=4.4.1)` and `rstan (&gt;=2.32.6)` simply run the `run_regression.R` script within the appropriate directory for the data partition of interest. The inputs are list in the R_data file as: P: number of partitions; N: number of records; S: number of sites per partition; Y: number of years; XY: year; XS: survey site; y: survey specific elephant numbers; survey_area (area of the survey); years (list of years from 1963-2015); sites (an anonymized code name for each site given the sensitivity of information about elephant populations); P (a number representing each of the 4 partitions in the data set); and XP (the vector of partitions for each survey) and partition (the names of the 4 partitions) Stan code is provided for conducting the analysis is R ## Access information Data was derived from the following sources: * African elephant database [Elephant Database (africanelephantdatabase.org)](https://africanelephantdatabase.org/#:~:text=African%20Elephant%20Range%20\(2015\)%20All%20materials%20on%20this%20site%20are) We have anonomized the site names in the R_data files to ensure compliance with the IUCN protocols and the stipulations for the use of the data by the African Elephant Specialist Group