2015-02-11 72 views
0

我試圖創建中的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 < - c(1)到c(178),它的確如此,但隨後變得暗淡無光。我嘗試將cms(r = 1,alpha = 0.01)改爲(r = 21),同時改變初始人口變化,但沒有增加,我錯過了什麼?瞭解R使得將是小東西,但我只是不停地失蹤了 任何幫助,將不勝感激

+0

跟進@ BondedDust的回答是:邏輯方程的更常見的形式在生態學中是'r * n *(1-n/K)',其中'K'是承載能力(=只要r> 0,穩定平衡值,K> 0,n(0) > 0')。這可能會使事情更容易理解。 – 2015-02-11 20:52:00

回答

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起始值,變化率將是負的當α大於一百七十八分之一時,將用α==一百七十八分之一FLATLINE,並且將物流當α少比1/178。

要轉到從300到200,你會不斷的α= 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