Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/seananderson/heavy-tails

Black-swan events in animal populations
https://github.com/seananderson/heavy-tails

Last synced: 12 days ago
JSON representation

Black-swan events in animal populations

Awesome Lists containing this project

README

        

---
output:
md_document:
variant: markdown_github
---

# Black-swan events in animal populations

[![DOI](https://zenodo.org/badge/24315125.svg)](https://zenodo.org/badge/latestdoi/24315125)

This repository contains code for an analysis of heavy-tailed
population dynamics for animal populations. It accompanies the paper:

Anderson, S.C., T.B. Branch, A.B. Cooper, N.K. Dulvy. Black-swan
events in animal populations. In press at Proceedings of the
National Academy of Sciences.

To recreate the analysis, first you will need the following R
packages installed:

```{r, eval=FALSE}
install.packages(c("rstan", "dplyr", "plyr", "reshape2", "ggplot2", "gridExtra",
"RColorBrewer", "grImport", "TeachingDemos", "metRology", "xtable", "devtools",
"skewt", "foreach", "Rcpp", "png"))
devtools::install_github("sckott/rphylopic")
```

Theoretically, you should be able to run the entire analysis by sourcing the following R file:

```{r, eval=FALSE}
source("analysis/make.R")
```

However, many of the analyses will take a very long time to run (multiple days), and you might run into minor issues with changes to R packages over time. Therefore, it is probably more useful to open the file `analysis/make.R` and work through the analysis files as they are called. Alternatively, the `.R` files are named in the order they should be run. Files starting with the same number can be run in any order. These numbered files assume that your R working directory is the `analysis` folder. Output from a number of the Stan models is cached in `.rds` files that will be available with a freshly cloned repository. Delete these files to force the models to be fit again.

## Data

The `analysis/gpdd/` folder contains data from the Global Population Dynamics
Database:

NERC Centre for Population Biology, Imperial College (2010). *The Global
Population Dynamics Database Version 2*.

The file `analysis/brook-etal.csv` contains a copy of the data from the
supplemental Excel spreadsheet in:

Brook, B.W., Traill, L.W. & Bradshaw, C.J.A. (2006).
Minimum viable population sizes and global extinction risk are unrelated.
*Ecol. Lett.* 9, 375-382.

## Package versions

It's possible that some portions of the analysis were run with earlier versions of R packages, but the versions of R packages installed at the time of publication were:

```{r, results='hide', echo=FALSE, message=FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>"
)
library(dplyr)
pkgs <- c("rstan", "dplyr", "plyr", "reshape2", "ggplot2", "gridExtra",
"RColorBrewer", "grImport", "TeachingDemos", "metRology", "xtable", "devtools",
"skewt", "foreach", "Rcpp", "png")
x <- devtools::session_info(pkgs = pkgs)
x <- as.data.frame(x$packages)
x <- dplyr::filter(x, package %in% pkgs) %>%
dplyr::select(-`*`, -date, -source) %>%
dplyr::arrange(package)
```

```{r, echo=FALSE, results=TRUE}
x
```