Introduction

In this exercise, you will explore a stochastic implementation of the Levins metapopulation model, modified to assume a finite number of habitat patches. The aim is to understand how patch occupancy changes over time depending on colonisation and extinction probabilities, the number of patches, and initial conditions.

This model assumes that:

We simulate this process for a number of time steps and track the overall occupancy.

Base Model Code

Cut and paste this code into R so you can use the function later.

simulate_metapop <- function(num_patches, c , e, 
                             time_steps, initial_occupied) {

  patches <- rep(FALSE, num_patches)
  patches[sample(1:num_patches, initial_occupied)] <- TRUE

  occupancy_record <- numeric(time_steps)

  for (t in 1:time_steps) {
    new_patches <- patches

    for (i in 1:num_patches) {
      if (patches[i]) {
        new_patches[i] <- runif(1) > e
      } else {
        colonize_prob <- c * mean(patches)
        new_patches[i] <- runif(1) < colonize_prob
      }
    }

    patches <- new_patches
    occupancy_record[t] <- mean(patches)
  }

  return(occupancy_record)
}

This is how you use the function - make sure it works for you.

Note that your graph will look different to this one, since the model is stochastic.

# Set the parameters
nPatch <- 150 
cVal <- 0.5
eVal <- 0.3

# Run the model
result <- simulate_metapop(num_patches = nPatch, c = cVal, e = eVal, 
                           time_steps = 100,
                           initial_occupied = ceiling(nPatch / 10))

# Plot the result, including labels
plot(result, type = 'l', col = 'darkgreen', lwd = 2,
     ylab = "Proportion Occupied", xlab = "Time",
     main = paste0("Stochastic Levins Model (",nPatch," patches)"), ylim = c(0,1))

# Add a line for Levins' deterministic equilibrium
abline(h = 1 - eVal / cVal, col = "red", lty = 2)

You should see that the proportion of occupied patches bounces around the deterministic equilibrium of \(1 - (e/c)\). This “bouncing around” is caused by the stochastic nature of the model - it is probabilistic. On average, in the long run, the equilibrium is predictable.

Let’s explore the model further.


Exercise 1: Sensitivity to Colonisation Rate

[This recaps some ideas from the simple deterministic Levins model, you can skip it if you are comfortable with that.]

Try different values for c (e.g. 0.1, 0.3, 0.5, 0.7) while keeping e = 0.3 constant.

Tasks

  • Plot the time series for each c value.
  • Overlay the deterministic equilibrium \(\hat{p} = 1 - e/c\) as a dashed red line.
  • Compare how the system behaves.

Questions

  • What happens to occupancy when colonisation is too low (i.e. \(c \leq e\))? How might this relate to isolated nature reserves?
  • How much extra colonisation capacity is needed to ensure persistence? What might this mean for designing corridors or stepping-stone habitats?
  • Why does the occupancy level off when colonisation is high? What limits further gains in patch occupancy, even with strong connectivity?

Exercise 2: Effect of Patch Number

Try simulations with 10, 30, 100, and 300 patches, keeping c = 0.5 and e = 0.3 constant.

Tasks

  • Run the simulation for each num_patches.
  • Plot the occupancy time series for each.

Questions

  • Which patch network sizes show greater fluctuation or risk of extinction?
  • How could patch number influence the reliability of conservation outcomes?
  • In fragmented landscapes, how many patches might be needed to maintain viable metapopulations over time?

Exercise 3: Exploring Initial Conditions

Try setting initial_occupied to 0, 10, 50, and 100 with 100 patches, and observe how the model behaves.

Tasks

  • Plot how quickly the system approaches equilibrium from different starting points.

Questions

  • If a species is reintroduced into a small number of patches, how quickly might it spread? Under what conditions might it fail to establish?
  • What do the results suggest about the number of individuals or populations needed to “kick-start” recovery?
  • How should this inform strategies like species reintroductions or habitat restoration?

Wrap-Up Discussion