Keeping track of immunity

Adam Kucharski Share this page

Dengue fever does the opposite of what you might expect. Unlike many diseases, if you've had this tropical virus and recovered, you might actually be worse off. In the aftermath of an infection like chickenpox, your new antibodies will step in to stop a repeat of the illness. However, a second exposure to the dengue virus can be far more severe than the first, even life threatening.


After a bout of dengue fever, mosquitoes will be a particularly unwelcome sight.

Past infections are not just important when faced with dengue fever though. Malaria and influenza are two other diseases in which a person's history of infection and immunity will decide the result of later exposures. The picture we have of these infections is actually formed from several pieces — the many strains that make up the disease.

Take flu, for example. Not long after a person develops immunity to it, the virus will change its cloak of proteins and your immune system will no longer be able to recognise it effectively. Over the years many different flu strains will appear in a population. However, keeping track of all these strains, and piecing together how they affect our immunity, is a problem. If there were only two strains, it would be simple. A person could have been infected by one of four combinations: neither strain; the first strain; the second; or both. But every new strain that appears doubles the possible combinations of infections a person could have had. For $n$ number of strains we would therefore need to track $2^ n$ different infection histories, as each combination could mean a different level of protection.

For dengue fever, this isn't too bad — it only has four main strains. But whether aware of it or not, the average person will encounter dozens of separate flu viruses over their lifetime. Our research group works on ways to deal with the resulting millions, if not billions, of possibilities.

A simple solution?

When faced with a problem they can't solve, mathematicians generally have two choices. They must either make more assumptions, or fewer conclusions. If we only look at people's current immunity, and don't mind too much about all the possible different past infections, we can look at flu behaviour using several linked versions of the so-called SIR model, one for each strain. In a SIR model the population is divided into three classes, susceptible to the disease, infected and recovered (hence the acronym SIR). The rate at which people pass from one class to another is described by differential equations, which depend on parameters that capture the characteristics of the particular strain (an overview of the SIR model can be found in the Plus article The mathematics of diseases).

The links between the SIR models come in the form of competition between different strains — often one flu strain will trigger immunity that also works against another variant — and mutation. As the virus inside an infected person mutates they pass to the relevant SIR model for the new strain. Using these linked models we can then simulate how the diseases spread, that is, how many people are likely to be infected at any given time.

Although this won't help us understand the nuts and bolts of the immune system, it does mean that we can quickly and easily look at some of the more general quirks of flu. One of these is its tendency to evolve unevenly. Despite the virus mutating often, flu strains tend to be fairly similar for a couple of years, then suddenly there will be a "jump" to a strain that is really quite different. Researchers have shown that, even if we only include current immunity, a simple model will reproduce these jumps from one cluster of strains to the next.

SIR models

Linking together several SIR models, strains will naturally cluster together in simulations of epidemics (each strain is a different colour).

Why is this useful? It shows that we don't have to include lots of complicated things in the simulation to get these jumps: even a simple set of interactions can cause them. And because we are using fairly simple differential equations in the models, we can analyse them easily, seeing how the level of infection changes over time.

Building the wrong defences

Immune system and Marigot line

Our immune system and the Maginot Line: they may have a few things in common.

After the First World War France built the Maginot Line, a mighty defence against a possible repeat of the conflict. Unfortunately, military tactics quickly changed and by the next war it had been rendered almost useless. There is evidence that our immune systems could be doing the same, building up defences to past dangers rather than current and future threats. Immunologists call it original antigenic sin: rather than develop antibodies to every new virus that is encountered, the immune system instead reproduces the reaction to similar viruses it has already seen, at the expense of developing new immunity. This means that past strains, and the order in which you get them, could be very important. So far we've simplified how immunity works though. If the human immune system does these bizarre things, we want to be able to look at the effects it might have on epidemics.

How can we study the effects of all these past strains? We've discussed how researchers adapt simple models, where everyone in a population can be put in one of just three boxes (susceptible, infective or recovered), but now let's look at the other extreme, with the population treated as individuals. These aptly named individual-based models allow us to look at things like original antigenic sin.

Say we simulated epidemics in a group of a million people. Rather than look at every possible combination of infection a person might have had (of which there could be billions), we can track each individual, and store information about what they've caught (and whether original antigenic sin is messing things up). It's like running an experiment inside a computer: we won't capture every possibility, but we'll get a good idea of what can often happen. And because we're looking at an experiment with a million people, rather than trying to study billions of events that might happen, its often much quicker to get results.

SIR versus individual models.

We can put everyone in one of three boxes, or treat them all as individuals.

Introducing randomness

We can simulate the epidemics in an individual-based model by assuming that people randomly pass on disease and recover, which is actually much closer to the unpredictability of real life than the clockwork-like SIR model. Looking at this randomness, also known as stochasticity, allows us learn more about how epidemics take off as well.

Epidemiologists use a number called $R_0$ to describe how easily a disease could spread. It is defined as the average number of people an infectious individual will go on to infect, assuming that no-one in the population is immune. If people transmit infection at a rate $β$ and recover at rate $\gamma $ (so the average duration of the disease is $1/\gamma $) then

  \[ R_0=\frac{\beta }{\gamma }. \]    

If $R_0$ is greater than one, the disease might cause an epidemic, as every infected person will on average infect more than one other person. It won’t always cause a big outbreak though, and we can calculate the probability that it won’t. Let’s call this probability $P.$ If initially one person has the disease, two things could happen: they pass it on, or recover without passing it on. This is known as a branching process: each branch represents a possible event.

How can we work out the probabilities of these two outcomes? We compare the rate at which each one occurs to the total rate of infection and recovery. The probability the infected person will recover before transmitting the disease on is therefore
  \[ \frac{\gamma }{\beta + \gamma }. \]    
A branching process

The branching process for the start of an epidemic, and the corresponding probabilities.

Likewise, the probability of the initial infectious person passing on the disease before recovering is

  \[ \frac{\beta }{\beta + \gamma }. \]    

If they do pass it on, we now have two people with infections that could die out, each with probability $P$. As it’s the start of the epidemic, and there are still plenty of susceptible people, these probabilities won’t really affect each other: they are independent. We can therefore multiply the two $P’s$ together to get the probability that neither of these infected people will cause an epidemic ($P^2$). So the probability that the infected person passes on the disease but that neither of the infected people cause an epidemic is

  \[ \frac{\beta }{\beta +\gamma }P^2. \]    

We can put all this into one equation. The probability that one person won’t cause an outbreak ($P$) is equal to the probabilities of the two possible outcomes, added together: that they infect someone else, and neither of these two causes an epidemic; and that the original person recovers without infecting someone else:

  \[ P=\frac{\beta }{ \beta +\gamma }P^2+\frac{\gamma }{\beta +\gamma }. \]    

Even though it describes quite a complex process, this is just a simple quadratic equation. It has two solutions, but as $P$ is a probability, we are only interested in the solution between 0 and 1. This works out to be

  \[ P=\frac{\gamma }{\beta }=\frac{1}{R_0}. \]    

So if a disease has an $R_0$ of more than one, it may still die out, with the above probability. The start of an epidemic is a haphazard time for a disease, and whether it causes a big outbreak and or fizzles out can just be down to luck!

Stochastic models

Three possible outbreaks in a stochastic model, starting with one person infective. Even though this disease has R0 = 3, one third of the outbreaks will fizzle out without causing an epidemic (green line).

These big individual-based models have already been used to look at how new strains emerge. One of the big mysteries about influenza is its limited diversity; unlike measles or HIV, very few flu strains are around at any one time — in each power struggle, new variants seem to either displace the old ones, or die out without taking hold. One theory, suggested by researchers using these models, is that two types of immunity work against flu: the long term, strain-specific one which we knew about already; and a short term defence, which works against any invading strain. If we know that this could be happening, it could also improve how we approach future research into influenza outbreaks.

Choosing the right assumptions

There are drawbacks to these highly detailed models though. Storing, and updating, all the necessary information for a large number of individual people can take a huge amount of time. Even as computers get faster, these complex simulations can still take a while. Also, unlike the simple models, we can't analyse the equations easily if something odd pops up in our results — such as strains clustering together as they evolve.

Whenever we look at diseases, especially those made up of many different strains, it's all about taking the right approach. If we want to look at lots of things quickly and be able to analyse the maths behind the simulation, we need a simple system of equations, like the SIR model. When dealing with the appearance of pandemics, and other new infections, we've seen that it's important to think about how stochasticity can cause infections to die out. And to study original antigenic sin, it's essential we look at all the past infections, and the order in which they happened.

Our research group is working on ways of bringing aspects of these different approaches together: by adding randomness into the simple models, or trying to understand the complicated bits of the immune system with methods that aren't so time-consuming. Deciding what to include, and what to leave out, is often one of the biggest difficulties in my work. Even if we include as much detail as possible in the model, one bad assumption can make potentially good research far less useful. I think the economist John Maynard Keynes summed it up nicely when he said, "it is better to be approximately right than precisely wrong".

Perhaps surprisingly, given the attention that flu pandemics receive, regular seasonal epidemics have contributed far more to influenza deaths in the last century. Each year the disease kills an estimated half a million people worldwide. However, by looking at how all these different strains interact, mathematics can help us build a better picture of how diseases like this behave and, perhaps, how they could be controlled.

About the author


Adam Kucharski is a PhD student in applied mathematics at the University of Cambridge. His research covers the dynamics of infectious diseases, focusing on influenza in particular.



Very interesting and clearly written. I always wondered how this was modeled.
Thanks for taking the time to write about it.


HONORED SIR, Your topic is very informative, but I need more information. Could you perhaps give me some details on the mathematical model of how calculus is used in disease?