密度依赖性增长

时间:2015-02-11 19:04:15

标签: r data-modeling

我正在尝试在R中创建一个图表,以显示一个人口的承载能力,使用的示例是:

install.packages("deSolve", dependencies = TRUE)

clogistic <- function(times, y, parms){
n <- y[1]
r <- parms[1]
alpha <- parms [2]
dN.dt <- r * n * (1 - alpha * n)
return(list(c(dN.dt)))
}

prms <- c(r = 1, alpha = 0.01)
init.N <- c(1)
t.s <- seq(0.1, 10, by = 0.1)
library(deSolve)
out <- ode(y = init.N, times = t.s, clogistic, parms = prms)

plot(out[,1], out[,2], type="l", xlab = "Time", ylab = "N", col = "blue", lwd = 2)

现在我正在使用它来尝试显示178的起始人口,15个时间步长增加21。但是当我尝试改变配方时,它会减少并在一个步骤后降至最低点,并在剩余的时间内保持低谷。 我已经尝试将init.N&lt; - c(1)更改为c(178),但它已经完成但最终结束了。我已经尝试将prms&lt; - c(r = 1,alpha = 0.01)改为(r = 21,随着初始种群变化的变化而没有,但它只是没有增加。我错过了什么?知道R它会变小,但我只是一直想念它。 任何帮助将不胜感激。

1 个答案:

答案 0 :(得分:2)

这是正在整合的微分方程:

 dN.dt <- r * n * (1 - alpha * n)

如果你想要一个n = 200的渐近线,那么将alpha设置为1/200,这样当n达到200时,变化率将变为零:

prms <- c(r = 1, alpha = .005)
init.N <- 178
t.s <- seq(0.1, 10, by = 0.1)
library(deSolve)
out <- ode(y = init.N, times = t.s, clogistic, parms = prms)

plot(out[,1], out[,2], type="l", xlab = "Time", ylab = "N", col = "blue", lwd = 2)

enter image description here

当起始值为178时,当alpha大于1/178时,变化率为负,alpha == 1/178时变化为flatline,当alpha小于1/178时变化率为logistic。

要从300到200,你将保持alpha = 1/200并从300开始:

prms <- c(r = 1, alpha = 1/200)
init.N <- c(300)
t.s <- seq(0.1, 10, by = 0.1)
out <- ode(y = init.N, times = t.s, clogistic, parms = prms)
plot(out[,1], out[,2], type="l", xlab = "Time", ylab = "N", col = "blue", lwd = 2)

enter image description here