2. DD.FUNCTION <- function(ALPHA, BETA, Fi, n) {Fi*ALPHA*exp
(-BETA*n)}: This passes the two density dependent parameters, the DI (densi-
ty-independent) fertility coefficient and total population size, and passes back
the new fertility as defined by equation (3.26). Parameter values are set at a ¼ 1, b
¼ 2 10
5
, which produces a stable equilibrium of 80782.
3. POP.DYNAMICS <- function(X): X contains the body size of the resident and
the body size of invader (this differs from the example in the introduction
which passed the multiplier for the invader). The function calculates the
growth rate of the invader. Unlike the example given in the introduction the
trajectory of the resident-only population is not followed.
4. Main program: This follows the approach outlined in the introduction. The
body size obtained from the elasticity analysis that follows is plotted onto the
contour surface.
R CODE:
rm(list¼ls()) # Clear workspace
LESLIE <- function(x,Maxage) # Function to generate Leslie matrix
{
M <- Maxage-1 # 1 less than the maximum age
age <- seq( from¼1, to¼Maxage) # vector of ages
Af <- 0 ;Bf <- 16; As <-1 ; Bs <- 0.5 # Parameter values
m <- rep(AfþBf*x, times¼Maxage) # number of female offspring
l <- exp(-(AsþBs*x)*age) # Survival to age
S <- matrix(0,Maxage,1) # Space for age-specific survival
S[1] <- l[1] # Survival to age 1
# Calculate the survival from t to tþ1
for ( i in 2:M) {S[i] <- l[i]/l[i-1]}
Fertility <- m*S # Top row of Leslie matrix
Dummy <- matrix(0,M,M) # Create a temporary matrix
diag(Dummy) <- S[1:M] # Assign survivals to diagonal
Leslie.matrix <- matrix(0, Maxage, Maxage) # Pre-assign space
Leslie.matrix[1,] <- Fertility # Add fertilities to top row
Leslie.matrix[2:Maxage,1:M] <- Dummy # Add dummy to appropriate
space
return(Leslie.matrix)
} # End of Leslie function
############### Density-dependence function ###############
DD.FUNCTION <- function(ALPHA,BETA,Fi,n) {Fi*ALPHA*exp
(-BETA*n)}
###############Population dynamics function ###############
POP.DYNAMICS <- function(X)
{
X.Resident <- X[1] # Body size of resident population
X.invader <
- X[2] # Body size of invader
ALPHA <-
1 ; BETA <- 2*10^-5 # Density dependence parameters
Maxage <- 50 # Maximum age
190 MODELING EVOLUTION