The Math of Vaccinations, Infection Rates, and Herd Immunity

Here in the US, we are, horribly, in the middle of a measles outbreak. And, as usual, anti-vaccine people are arguing that:

  • Measles isn’t really that serious;
  • Unvaccinated children have nothing to do with the outbreak; and
  • More vaccinated people are being infected than unvaccinated, which shows that vaccines don’t help.

A few years back, I wrote a post about the math of vaccines; it seems like this is a good time to update it.

When it comes to vaccines, there’s two things that a lot of people don’t understand. One is herd immunity; the other is probability of infection.

Herd immunity is the fundamental concept behind vaccines.

In an ideal world, a person who’s been vaccinated against a disease would have no chance of catching it. But the real world isn’t ideal, and vaccines aren’t perfect. What a vaccine does is prime the recipient’s immune system in a way that reduces the probability that they’ll be infected.

But even if a vaccine for an illness were perfect, and everyone was vaccinated, that wouldn’t mean that it was impossible for anyone to catch the illness. There are many people who’s immune systems are compromised – people with diseases like AIDS, or people with cancer receiving chemotherapy. (Or people who’ve had the measles within the previous two years!) And that’s not considering the fact that there are people who, for legitimate medical reasons, cannot be vaccinated!

So individual immunity, provided by vaccines, isn’t enough to completely eliminate the spread of a contagious illness. To prevent outbreaks, we rely on an emergent property of a vaccinated population. If enough people are immune to the disease, then even if one person gets infected with it, the disease won’t be able to spread enough to produce a significant outbreak.

We can demonstrate this with some relatively simple math.

Let’s imagine a case of an infection disease. For illustration purposes, we’ll simplify things in way that makes the outbreak more likely to spread than reality. (So this makes herd immunity harder to attain than reality.)

  • There’s a vaccine that’s 95% effective: out of every 100 people vaccinated against the disease, 95% are perfectly immune; the remaining 5% have no immunity at all.
  • The disease is highly contagious: out of every 100 people who are exposed to the disease, 95% will be infected.

If everyone is immunized, but one person becomes ill with the disease, how many people do they need to expose to the disease for the disease to spread?

Keeping things simple: an outbreak, by definition, is a situation where the number of exposed people is steadily increasing. That can only happen if every sick person, on average, infects more than 1 other person with the illness. If that happens, then the rate of infection can grow exponentially, turning into an outbreak.

In our scheme here, only one out of 20 people is infectable – so, on average, if our infected person has enough contact with 20 people to pass an infection, then there’s a 95% chance that they’d pass the infection on to one other person. (19 of 20 are immune; the one remaining person has a 95% chance of getting infected). To get to an outbreak level – that is, a level where they’re probably going to infect more than one other person, they’d need expose something around 25 people (which would mean that each infected person, on average, could infect roughly 1.2 people). If they’re exposed to 20 other people on average, then on average, each infected person will infect roughly 0.9 other people – so the number of infected will decrease without turning into a significant outbreak.

But what will happen if just 5% of the population doesn’t get vaccinated? Then we’ve got 95% of the population getting vaccinated, with a 95% immunity rate – so roughly 90% of the population has vaccine immunity. Our pool of non-immune people has doubled. In our example scenario, if each person is exposed to 20 other people during their illness, then they will, on average, cause 1.8 people to get sick. And so we have a major outbreak on our hands!

This illustrates the basic idea behind herd immunity. If you can successfully make a large enough portion of the population non-infectable by a disease, then the disease can’t spread through the population, even though the population contains a large number of infectable people. When the population’s immunity rate (either through vaccine, or through prior infection) gets to be high enough that an infection can no longer spread, the population is said to have herd immunity: even individuals who can’t be immunized no longer need to worry about catching it, because the population doesn’t have the capacity to spread it around in a major outbreak.

(In reality, the effectiveness of the measles vaccine really is in the 95 percent range – actually slightly higher than that; various sources estimate it somewhere between 95 and 97 percent effective! And the success rate of the vaccine isn’t binary: 95% of people will be fully immune; the remaining 5% will have a varying degree of immunity And the infectivity of most diseases is lower than the example above. Measles (which is a highly, highly contagious disease, far more contagious than most!) is estimated to infect between 80 and 90 percent of exposed non-immune people. So if enough people are immunized, herd immunity will take hold even if more than 20 people are exposed by every sick person.)

Moving past herd immunity to my second point: there’s a paradox that some antivaccine people (including, recently, Sheryl Atkinson) use in their arguments. If you look at an outbreak of an illness that we vaccinate for, you’ll frequently find that more vaccinated people become ill than unvaccinated. And that, the antivaccine people say, shows that the vaccines don’t work, and the outbreak can’t be the fault of the unvaccinated folks.

Let’s look at the math to see the problem with that.

Let’s use the same numbers as above: 95% vaccine effectiveness, 95% contagion. In addition, let’s say that 2% of people choose to go unvaccinated.

That means thats that 98% of the population has been immunized, and 95% of them are immune. So now 92% of the population has immunity.

If each infected person has contact with 20 other people, then we can expect expect 8% of those 20 to be infectable – or 1.6; and of those, 95% will become ill – or 1.52. So on average, each sick person will infect 1 1/2 other people. That’s enough to cause a significant outbreak. Without the non-immunized people, the infection rate is less than 1 – not enough to cause an outbreak.

The non-immunized population reduced the herd immunity enough to cause an outbreak.

Within the population, how many immunized versus non-immunized people will get sick?

Out of every 100 people, there are 5 who got vaccinated, but aren’t immune. Out of that same 100 people, there are 2 (2% of 100) that didn’t get vaccinated. If every non-immune person is equally likely to become ill, then we’d expect that in 100 cases of the disease, about 70 of them to be vaccinated, and 30 unvaccinated.

The vaccinated population is much, much larger – 50 times larger! – than the unvaccinated.
Since that population is so much larger, we’d expect more vaccinated people to become ill, even though it’s the smaller unvaccinated group that broke the herd immunity!

The easiest way to see that is to take those numbers, and normalize them into probabilities – that is, figure out, within the pool of all vaccinated people, what their likelihood of getting ill after exposure is, and compare that to the likelihood of a non-vaccinated person becoming ill after exposure.

So, let’s start with the vaccinated people. Let’s say that we’re looking at a population of 10,000 people total. 98% were vaccinated; 2% were not.

  • The total pool of vaccinated people is 9800, and the total pool of unvaccinated is 200.
  • Of the 9800 who were vaccinated, 95% of them are immune, leaving 5% who are not – so
    490 infectable people.
  • Of the 200 people who weren’t vaccinated, all of them are infectable.
  • If everyone is exposed to the illness, then we would expect about 466 of the vaccinated, and 190 of the unvaccinated to become ill.

So more than twice the number of vaccinated people became ill. But:

  • The odds of a vaccinated person becoming ill are 466/9800, or about 1 out of every 21
    people.
  • The odds of an unvaccinated person becoming ill are 190/200 or 19 out of every 20 people! (Note: there was originally a typo in this line, which was corrected after it was pointed out in the comments.)

The numbers can, if you look at them without considering the context, appear to be deceiving. The population of vaccinated people is so much larger than the population of unvaccinated that the total number of infected can give the wrong impression. But the facts are very clear: vaccination drastically reduces an individuals chance of getting ill; and vaccinating the entire population dramatically reduces the chances of an outbreak.

The reality of vaccines is pretty simple.

  • Vaccines are highly effective.
  • The diseases that vaccines prevent are not benign.
  • Vaccines are really, really safe. None of the horror stories told by anti-vaccine people have any basis in fact. Vaccines don’t damage your immune system, they don’t cause autism, and they don’t cause cancer.
  • Not vaccinating your children (or yourself!) doesn’t just put you at risk for illness; it dramatically increases the chances of other people becoming ill. Even when more vaccinated people than unvaccinated become ill, that’s largely caused by the unvaccinated population.

In short: everyone who is healthy enough to be vaccinated should get vaccinated. If you don’t, you’re a despicable free-riding asshole who’s deliberately choosing to put not just yourself but other people at risk.

13 thoughts on “The Math of Vaccinations, Infection Rates, and Herd Immunity

  1. Caleb Grayson

    “If you don’t, you’re a despicable free-riding asshole who’s deliberately choosing to put not just yourself but other people at risk.”

    this, in total avoidance of all the issues around the safety of vaccines ( for which there is a Federally created vaccine injury court protecting manufacturers from those they’ve injured ) shows your math is emotionally driven and proabbly explains why its not a comprehensive answer to the anti/vaxx debate.

    (btw, there is risk in everything — even driving to the clinic to get a vaccine.)

    Reply
    1. markcc Post author

      I love how you can conclude that my math is wrong on the basis of nothing in the math.

      Yes, there’s a vaccine injury court. That has absolutely nothing to do with whether or not vaccines are safe or effective. Like any other government program, what the creation of the VIC shows is: the government decided that needed to create it.

      Why?

      If you actually go back and look at why it was created: manufacturing vaccines is actually a low-profit industry, but one which produces an immense public good. If companies had to deal with lawsuits from purported vaccine victims, it wouldn’t be worth it for them to manufacture vaccines. So the government created a program to protect them.

      Of course nothing is risk free. There are people who are legitimately harmed by vaccines. But they’re not the ones that people like Atkinson like to promote. No one is getting autism or cancer from vaccines. And you know that – which is why you don’t bother even *trying* to refute the actual math, or discussing anything about the *actual*, rare causes of injuries due to vaccines.

      If you don’t have a legitimate medical reason to not be vaccinated, and you still choose not to be, then you *are* a despicable free-riding asshole.

      Reply
      1. Caleb Grayson

        “I love how you can conclude that my math is wrong on the basis of nothing in the math.”

        you’re so emotional you equate ‘emotionally driven’ with ‘wrong’.

        your math in incomprehensive. this is why you’re about to take math and use it to determine who is an asshole.

        Reply
    2. Fact-Check

      The “Federally created Vaccine Court” makes it _easier_ for people with legitimate claims to get compensation, by _lowering_ their burden of proof. To get money, people simply have to show that a condition did not exist before the vaccination, did exist after, and that the condition is one that vaccines are known to cause. People don’t need to prove that the vaccine actually caused the condition. Furthermore, people who are rejected by the Vaccine Court remain free to sue in regular courts.

      Reply
  2. Jason Almeter

    When you calculate the probabilities of illness, I think the second term should be for ‘unvaccinated’.

    Reply
  3. Daniel

    In the interest of catching more flies with math-laden honey, would you remove the last paragraph? It’s merely inflammatory, at the end of a great, facts-driven article. I just think you should leave the anti-vaccine people nothing but your arguments to discuss.

    Reply
    1. markcc Post author

      Nope. I wrote what I wrote, and I believe it. I’m not going to water it down just to make some twits happy.

      Reply
      1. Just another guy Website

        Keep up the good work. Judging from some of the squeals, you’ve hit the target (ignorance, error, and hysteria) quite accurately.

        Reply
  4. Nuño

    The math is the same, but pedagogically, if you’d written:

    > There’s a vaccine that’s 95% effective: out of every 100 people vaccinated against the disease, 95% are perfectly immune; the remaining 5% have no immunity at all.
    > The disease is highly contagious: out of every 100 people who are exposed to the disease, 95% will be infected.

    instead of

    > There’s a vaccine that’s 95% effective: out of every 100 people vaccinated against the disease, 95% are perfectly immune; the remaining 5% have no immunity at all.
    > The disease is highly contagious: out of every 100 people who are exposed to the disease, 94% will be infected.

    and propagated the changes, the explanation might be clearer, because I could distinguish P(vaccinated) from P(infected | exposed) by their numeric values at a glance, instead of having to do a double take.

    Reply
  5. spencer

    It would have been interesting to discuss the herd immunity threshold and the required vaccination rate to prevent outbreaks. The latter can be calculated from the basic reproduction number (R) and the vaccine efficacy (E) as (1-1/R)/E. For instance, measles infects 12-18 susceptible people per infection (say conservatively R=18), and is perhaps 97% effective (E=.97), so it requires over 97% vaccination rate to prevent epidemics. [Source: https://en.wikipedia.org/wiki/Herd_immunity%5D

    Pertussis is another highly contagious disease (R=12-17). Unfortunately the vaccine is only ~80% effective (Schwartz 2016), meaning that even 100% vaccination rates would not lead to herd immunity. Thus vaccinating kids against whooping cough won’t lead to the eradication of the disease (with the current vaccine), although it will decrease the number of cases.

    In conclusion, it’s important to use the real numbers when calculating these things. Even small seeming changes (e.g. a 2% increase in vaccine efficacy) can lead to big differences in outcomes since many of the formulas involve ratios.

    Reply
  6. Pingback: Herd immunity | Hydrobates

  7. Peter Gerdes

    Good post but do you really believe there is some pool of mathematically sophisticated anti-vaxers out there to be convinced?

    I mean sure there was Serge Lange but I’m not totally sure how much even he believed his crazy views (he wouldn’t take up my challenge to inject himself with HIV+ blood while I used a popper .. his theory of the cause of AIDS).

    Reply

Leave a Reply