Member-only story
Forest Fires, Epidemics and Models
What can forest fires tell us about epidemic modelling?
Using code, we can simulate forest fires. This is often an introductory lesson in programming languages.
This simple model of a forest fire can inform us about the epidemic spread of diseases.
Setting up the lattice
In R, there is the igraphs package. This package can make lattice graphs.
The basic lattice sets up a grid where each vertex connects to its four adjacent neighbours. Mathematicians call that central vertex and those four neighbours the von Neumann neighbourhood.
test_lattice <- make_lattice(length = 5, dim = 2, nei = 1)
test_lattice %>% plot(layout = layout_on_grid)
For forest fires, diagonal connections to each vertex are important too.
There is no setting in the make_lattice function for these extra connections. We need to create the extra edges, and add them.
extra_edges_df <- tibble(x = as.numeric(1:20,
w = case_when(x %% forest_length == 1 ~ NA_real_,
TRUE ~ x + forest_length - 1),
z = case_when(x %% forest_length == 0 ~ NA_real_,
TRUE ~ x + forest_length + 1)) %>%
pivot_longer(cols = 2:3,
names_to = "column",
values_to =…