Friday, March 6, 2015

R32. Logistic Growth in R

Logistic growth of fisheries, or other populations, will go towards a Carrying Capacity. The growth will start exponentially and is S-shaped.


For a specific rate of growth, and Carrying Capacity, the Population is shown.


The vertical line shows the maximum derivative, that is where the maximum growth occurs.

# ex32.R
library(nnet)
r <- .25 # growth rate / yr
K <- 100 # carrying capacity
t <- 40 # number of years
num <- numeric(t+1)
num[1] <- 1
for (i in 1:t) {
  num[i+1] <- num[i]+r*num[i]*(1-num[i]/K)
}
plot(num, type = 'l', col = 'blue',
     xlab = 'Year', ylab = 'Number',
     main = "Growth rate: 0.25, Carrying Capacity = 100")
abline(v=which.is.max(diff(num)))

Output:

No comments:

Post a Comment