################ POP.DYNAMICS FUNCTION ################
POP.DYNAMICS <- function(ALPHA, Coeff)
{
ALPHA.resident <- ALPHA # Resident value
ALPHA.invader <- ALPHA*Coeff # Invader value
REMAINDER THE SAME AS IN INVASIBILITY ANALYSIS
} # End of function
#################### MAIN PROGRAM ####################
par(mfrow¼c(2,2)) # Divide graphics page into quadrats
# Call uniroot to find optimum
minA <-10; maxA <-40 # Limits of search for alpha
Optimum <- uniroot(POP.DYNAMICS, interval¼c(minA,
maxA),0.995)
Best.A <- Optimum$root # Store optimum Alpha
print(Best.A) # Print out optimum
N.int <- 30 # Nos of intervals for plot
A <- matrix(seq(from¼minA, to¼maxA, length¼N.int), N.int,1)
Elasticity <- apply(A,1,POP.DYNAMICS, 0.995)
plot(A, Elasticity, type¼’l’)
lines(c(minA, maxA), c(0,0)) # Add horizontal line at zero
# Now plot Invasion exponent when resident is optimal
Coeff <- A/Best.A # Convert A to coefficient
Invasion.coeff <- matrix(0,N.int,1) # Allocate space
# Calculate invasion coefficient
for (i in 1:N.int){ Invasion.coeff[i] <- POP.DYNAMICS(Best.A,
Coeff[i])}
plot(A, Invasion.coeff, type¼’l’) # Plot invasion coeff vs alpha
points(Best.A,0, cex¼2) # Add predicted optimum
# Plot N(tþ1) on N(t) for best model
N <- 1000 # Nos of data points
N.t <- seq(from¼1, to¼N) # Values of N(t)
N.tplus1 <- matrix(0,N) # Allocate space
# Iterate to get N(tþ1) on N(t)
for ( i in 1:N){N.tplus1[i] <- DD.FUNCTION(Best.A, N.t[i], N.t
[i])}
plot(N.t, N.tplus1, type¼’l’) # Plot N(tþ1) on N(t)
# Plot N(t) on t
N <- matrix(0,100) # Allocate space
N[1] <-
1 # Initial value of N(t)
for (i in 2:100){N[i]<- DD.FUNCTION(Best.A, N[i-1], N[i-1])}
plot(seq(from¼1, to¼100), N, type¼’l’, xlab¼’Generation’,
ylab¼’Population’)
OUTPUT: (Figure 3.17)
216 MODELING EVOLUTION