# 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 = "y",

values_drop_na = TRUE) %>%

select("x", "y")

The *add_edges* function takes matrices in a counter-intuitive way.

`extra_edges_v <- cbind(extra_edges_df$x, extra_edges_df$y)`

%>% t() %>% c()

We can then add these edges on.

`test_lattice_added <- test_lattice %>% add_edges(edges = extra_edges_v)`

test_lattice_added %>% plot(layout = layout_on_grid)

Mathematicians call a vertex and its eight neighbours the **Moore neighbourhood**.

We can then set up fixed or probabilistic rules for the three different states:

**Alive:**the tree is green, and could be set on fire by neighbouring trees.**On fire:**the tree is on fire, meaning it can set fire to its neighbours.**Burnt:**the tree has burnt. The tree cannot ignite neighbouring trees.

For testing purposes, I ran ten simulations. These are the outcomes:

# What we learn

There are two types of models:

**Deterministic:**there are rules to follow. The initial state and these rules determine the eventual outcome. There is no uncertainty: only unawareness of what that outcome will be.**Stochastic:**there are rules, but each step is uncertain. Alight trees may not set fire to neighbouring trees. Trees may take a while to burn out. This is a family of random variables changing over time. The technical term is that we run a**stochastic model**.

## What do forest fire models teach us about epidemics?

The connection is an analogy. The same model can represent both a forest fire and an epidemic. Green trees are like susceptible people. Burning trees are akin to infectious people. Once burnt out by the virus, removed people are no longer in the susceptible population. This removal is by death or immunity.

As a result, this simple model teaches us many things:

**Seeds:**the number of initial cases is important for understanding the spread of a disease.**Contacts:**the people on the ‘edge’ have fewer neighbours. These people are less likely to get infected.**Infectious period:**If a tree keeps burning, it has more time to ignite green neighbours. Likewise, a long infectious period increases the likelihood of transmission.**Transmission:**the rules about transmissions affect how fast a disease spreads. We can enhance the simple model for forest fires, to include wind effects.**Immunity:**Fire-breakers can contain a forest fire. Vaccinations slow down the spread of a disease, protecting the community.

Simple models can inform us about basic principles and uncertainty.

The R code for simulations is available on GitHub and R Pubs. I adapted code from a comment on Stack Overflow.