https://github.com/patrickbarks/popmods
R package to obtain tidy output from continuous-time population models in ecology
https://github.com/patrickbarks/popmods
Last synced: about 1 month ago
JSON representation
R package to obtain tidy output from continuous-time population models in ecology
- Host: GitHub
- URL: https://github.com/patrickbarks/popmods
- Owner: patrickbarks
- License: other
- Created: 2018-06-08T08:17:07.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2018-10-12T20:43:16.000Z (almost 8 years ago)
- Last Synced: 2025-10-26T01:27:52.374Z (9 months ago)
- Language: R
- Homepage:
- Size: 1.98 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.Rmd
- License: LICENSE
Awesome Lists containing this project
README
---
output: github_document
---
[](https://ci.appveyor.com/project/patrickbarks/popmods)
[](https://travis-ci.org/patrickbarks/popmods)
[](https://codecov.io/github/patrickbarks/popmods?branch=master)
```{r, echo = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/img/",
eval=TRUE,
dpi = 150,
fig.width = 4.5,
fig.height = 3
)
library(ggplot2)
tt <- theme_get() +
theme(legend.position = c(0.98, 0.97),
legend.justification = c(1, 1),
text = element_text(size = 9),
axis.title = element_text(size = 9.5))
theme_set(tt)
```
popmods
=========
Easy numerical analysis of continuous-time population models in ecology.
Models currently supported:
- logistic growth
- delayed-logistic growth
- Lotka Volterra (predator-prey)
- Lotka Volterra (two-species competition)
- rock-paper-scissors intransitive competition
- rock-paper-scissors-lizard-spock
- SIR epidemiological model
## Installation
Install the development version from GitHub with:
```{r, eval=FALSE}
devtools::install_github("patrickbarks/popmods")
#
# or
#
install.packages("remotes") # smaller and quicker to install than devtools
remotes::install_github("patrickbarks/popmods")
```
## Usage
```{r, message=FALSE}
library(popmods)
library(ggplot2)
# vector of time points at which to evaluate models
t <- seq(0, 50, 0.01)
```
###### Delayed logistic
```{r Delayed-logistic}
df_dl <- logistic_delay(time = t, init_n = 10, r = 1.1, k = 500, tau = 1.12)
ggplot(df_dl, aes(time, abundance)) +
geom_line(lwd = 1.2)
```
###### Lotka-Volterra predator-prey
```{r Lotka-Volterra-predator-prey}
df_lvpp <- lotka_volterra(time = t, init_n = 50, init_p = 30, r = 0.8, c = 0.04,
a = 0.2, m = 0.3)
ggplot(df_lvpp, aes(time, abundance, color = population)) +
geom_line(lwd = 1.2) +
scale_color_brewer(type = 'qual', palette = 6)
```
###### Rock-paper-scissors-lizard-spock competition
```{r R-P-S-L-K-competition}
df_rpslk <- rpslk(time = t, init_r = 0.02, init_p = 0.02, init_s = 0.03,
init_l = 0.9, init_k = 0.03, b = 0.7)
ggplot(df_rpslk, aes(time, proportion, color = strategy)) +
geom_line(lwd = 1.2) +
scale_color_brewer(type = 'qual', palette = 6)
```
###### SIR epidemiological model
```{r SIR-epidemiological-model}
df_sir <- sir(time = t, init_s = 0.9999, init_i = 0.0001, init_r = 0,
gamma = 0.6, beta = 0.08)
ggplot(df_sir, aes(time, proportion, color = status)) +
geom_line(lwd = 1.2) +
scale_color_brewer(type = 'qual', palette = 6)
```
## Contributions
All contributions are welcome. Please note that this project is released with a [Contributor Code of Conduct](CONDUCT.md). By participating in this project you agree to abide by its terms.