Skip to content

Instantly share code, notes, and snippets.

@TCornulier
Last active February 23, 2021 17:53
Show Gist options
  • Save TCornulier/0a9bdf0258d418b44cb32aa78522b6b4 to your computer and use it in GitHub Desktop.
Save TCornulier/0a9bdf0258d418b44cb32aa78522b6b4 to your computer and use it in GitHub Desktop.
change extension

Royama’s log-linear AR2 model phase plane

11/02/2021

Here is some R code to draw Royama’s phase plane for the log-linear AR2 model (Royama, T. 1992. Analytical Population Dynamics), as used in this paper.

plot(1, 1, col= NULL, xlim= c(-2, 2), ylim= c(-1, 1), 
    xlab= expression(paste("1 + ", Omega[1])), 
    ylab= expression(Omega[2]), pch= 21, bg= NULL, cex.lab= 1.2)

segments(c(-2, 0, -2, 0), 
    c(-1, 1, -1, -1), 
    c(0, 2, 2, 0), 
    c(1, -1, -1, 0), 
    col= grey(0.4))

curve(-x^2 / 4, -2, 2, col= grey(0.4), add= T)

cycleperiod<- c(3, 5:100)

w= 2 * pi / cycleperiod

for(i in 1){
    curve(-0.25 * x^2 * (tan(w[i])^2 + 1), -sqrt(1 / (0.25 * (tan(w[i])^2 + 1))), 0,
    add= T, col= grey(0.4))
}

for(i in 2:97){
    curve(-0.25 * x^2 * (tan(w[i])^2 + 1), 0, sqrt(1 / (0.25 * (tan(w[i])^2 + 1))),
    add= T, col= grey(0.4))
}

text(x= c(-1.34, -0.65, 0.05, 0.47, 0.73, 0.91, 1.04), 
    y= c(-0.516, -0.516, -0.516, -0.516, -0.516, -0.516, -0.516), 
    labels= 2:8, col= grey(0.5), cex= 1.2)

The triangle represents the region of the parameter space that produces stationary dynamics, either stable (top part) or cyclical (below the parabola, with numeric labels indicating some of the shorter cycle lengths).

---
title: "Royama's log-linear AR2 model phase plane"
date: "`r format(Sys.time(), '%d/%m/%Y')`"
editor_options:
chunk_output_type: console
output: github_document
---
Here is some R code to draw Royama's phase plane for the log-linear AR2 model (Royama, T. 1992. Analytical Population Dynamics), as used in [this paper](https://scholar.google.co.uk/scholar?hl=en&as_sdt=0%2C5&q=Europe-Wide+Dampening+of+Population+Cycles+in+Keystone+Herbivores&btnG=).
```{r, fig.height= 7.5, fig.width= 8}
plot(1, 1, col= NULL, xlim= c(-2, 2), ylim= c(-1, 1),
xlab= expression(paste("1 + ", Omega[1])),
ylab= expression(Omega[2]), pch= 21, bg= NULL, cex.lab= 1.2)
segments(c(-2, 0, -2, 0),
c(-1, 1, -1, -1),
c(0, 2, 2, 0),
c(1, -1, -1, 0),
col= grey(0.4))
curve(-x^2 / 4, -2, 2, col= grey(0.4), add= T)
cycleperiod<- c(3, 5:100)
w= 2 * pi / cycleperiod
for(i in 1){
curve(-0.25 * x^2 * (tan(w[i])^2 + 1), -sqrt(1 / (0.25 * (tan(w[i])^2 + 1))), 0,
add= T, col= grey(0.4))
}
for(i in 2:97){
curve(-0.25 * x^2 * (tan(w[i])^2 + 1), 0, sqrt(1 / (0.25 * (tan(w[i])^2 + 1))),
add= T, col= grey(0.4))
}
text(x= c(-1.34, -0.65, 0.05, 0.47, 0.73, 0.91, 1.04),
y= c(-0.516, -0.516, -0.516, -0.516, -0.516, -0.516, -0.516),
labels= 2:8, col= grey(0.5), cex= 1.2)
```
> The triangle represents the region of the parameter space that produces stationary dynamics, either stable (top part) or cyclical (below the parabola, with numeric labels indicating some of the shorter cycle lengths).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment