Pandemic Modelling

This forum can be broken out into additional areas as topic trends begin to develop.

Pandemic Modelling

Postby Мастер » Wed Apr 01, 2020 12:01 pm

I'm sure this has been done to death, but I just like to work things out on my own.

Suppose there is a very large population, and a certain percentage pt are infected with some germ at time t.

Each period (day, week, whatever is appropriate for the disease), each person who is infected infects r0 other people randomly selected from the population. However, those who have already been infected are immune, and do not develop the disease.

So the percentage of people infected at time t is pt==pt-1*r0*(1-Pt-1), where Pt-1 is the cumulative percentage of people infected. So Pt==Pt-1+(Pt-1-Pt-2)*r0*(1-Pt-1).

It is probably possible to analyse this analytically, but I'm really tired, so I just pulled up a spreadsheet and did it numerically. Starting in all cases with an initial infection rate on day one of 0.001%, we have:

If r0=1.1, the pandemic reaches its peak on period 79, with about 0.44% of the population infected (that is, this is the highest rate of infection at one point in time). By this time, 9.3% of the population has been infected, but ultimately the cumulative infection rate will be 17.9%.

If r0=1.5, the pandemic reaches its peak on period 26, with about 7.24% of the population infected (that is, this is the highest rate of infection at one point in time). By this time, 37.8% of the population has been infected, but ultimately the cumulative infection rate will be 61.8%.

If r0=2.0, the pandemic reaches its peak on period 17, with about 19.5% of the population infected (that is, this is the highest rate of infection at one point in time). By this time, 63.6% of the population has been infected, but ultimately the cumulative infection rate will be 86.9%.

If r0=3.0, the pandemic reaches its peak on period 12, with about 40.6% of the population infected (that is, this is the highest rate of infection at one point in time). By this time, 104.4% of the population has been infected, but ultimately the cumulative infection rate will be 98.9%. The nonsensical numbers indicate a problem with the model - when r0 is high, a certain percentage of people will be infected by more than one already infected person, reducing the number of new infections somewhat.

Comments on the model/analysis? How to improve?
They call me Mr Celsius!
User avatar
Мастер
Moderator
Moderator
Злой Мудак
Mauerspecht
 
Posts: 23935
Joined: Tue Aug 02, 2005 2:56 pm
Location: Far from Damascus

Re: Pandemic Modelling

Postby Arneb » Wed Apr 01, 2020 2:05 pm

I can't, for lack of being intelligent mathematically, point out any errors in your math. I think what you are doing is basically the same is what this guy is doing in a numberphile video, but he somehow never gets above 100 % of people infected:
Watch on youtube.com


The place where I personally learned the most on the subject is 3blue1brown. Two videos, here, the first is more general (and thus maybe helpful with your problem, the second treats specific scenarios:

Watch on youtube.com

Watch on youtube.com
Non sunt multiplicanda entia praeter necessitatem
User avatar
Arneb
Moderator
Moderator
German Medical Dude
God of All Things IT
 
Posts: 70075
Joined: Thu Nov 23, 2006 8:22 pm
Location: Potsdam, Germany

Re: Pandemic Modelling

Postby Мастер » Wed Apr 01, 2020 6:03 pm

Arneb wrote:but he somehow never gets above 100 % of people infected:


The flaw is the assumption that every infected person infects some number of new people. If there are lots of infected people, then their different groups of new people to infect are going to have to overlap. So when lots of people are infected, sometimes it is "this person is exposed to two infected people" instead of "these two different people are exposed to one infected person each".

The thing that I didn't really appreciate was that a disease can easily die out with well less than 100% of the people infected, even if each diseased person infects more than 1 new victim. That "herd immunity" can occur with well less than 100% infected.
They call me Mr Celsius!
User avatar
Мастер
Moderator
Moderator
Злой Мудак
Mauerspecht
 
Posts: 23935
Joined: Tue Aug 02, 2005 2:56 pm
Location: Far from Damascus

Re: Pandemic Modelling

Postby g-one » Thu Apr 02, 2020 2:08 am

Is that maybe why they keep saying somewhere between 30 to 70 per cent of population could become infected, but I've not seen anyone mention more that 70% ?
striving to recognize the penultimate straw
User avatar
g-one
Illuminatus
Illuminatus
 
Posts: 2189
Joined: Tue Jul 12, 2016 6:18 am
Location: Melonville, Canada

Re: Pandemic Modelling

Postby Мастер » Thu Apr 02, 2020 5:12 am

g-one wrote:Is that maybe why they keep saying somewhere between 30 to 70 per cent of population could become infected, but I've not seen anyone mention more that 70% ?


Probably. My naïve thought was, if each infected person infects more than one other person, then eventually everyone will get the disease. But putting pen to paper, it's not true.
They call me Mr Celsius!
User avatar
Мастер
Moderator
Moderator
Злой Мудак
Mauerspecht
 
Posts: 23935
Joined: Tue Aug 02, 2005 2:56 pm
Location: Far from Damascus

Re: Pandemic Modelling

Postby Arneb » Thu Apr 02, 2020 6:00 am

I heard a mathematical biologist in a podcast yesterday saying that the proportion of not-susceptible people you need in a population to achieve herd immunity (and conversely, the proprortion of members in a population that a new pathogen will typiclcally infect before it dies out) is relatively easy to compute: It comes down to 1 minus the inverse of the basic reproduction number (R0; the average number of other members of the population someoe infects before becoming-non-infectious). So if SARS-CoV-2 has a basic reproduction number of around 2.5 (which was a typical result before social distancing), then herd immunity will develop when a proportion of 1 - 1/2.5 = /.4 =.6 of the population have become infected. That's the "60-70%" everyone's talking about.

Interstingly, it explains why we never totally get rid of measles. it has an R0 of around 15, so for the disease to die out as a result of herd immunity you need an immunization rate of more than 93 %. We don't get that high because, as they say in Italy, the mother of all idiots is always pregnant.
Non sunt multiplicanda entia praeter necessitatem
User avatar
Arneb
Moderator
Moderator
German Medical Dude
God of All Things IT
 
Posts: 70075
Joined: Thu Nov 23, 2006 8:22 pm
Location: Potsdam, Germany

Re: Pandemic Modelling

Postby Мастер » Thu Apr 02, 2020 6:18 am

Arneb wrote:I heard a mathematical biologist in a podcast yesterday saying that the proportion of not-susceptible people you need in a population to achieve herd immunity (and conversely, the proprortion of members in a population that a new pathogen will typiclcally infect before it dies out) is relatively easy to compute: It comes down to 1 minus the inverse of the basic reproduction number (R0; the average number of other members of the population someoe infects before becoming-non-infectious). So if SARS-CoV-2 has a basic reproduction number of around 2.5 (which was a typical result before social distancing), then herd immunity will develop when a proportion of 1 - 1/2.5 = /.4 =.6 of the population have become infected. That's the "60-70%" everyone's talking about.


I have heard this number, and I am trying to understand exactly what that means. That is in fact what prompted me to do this exercise.

If it means "each infected person will infect fewer than one new persons", then that follows pretty quickly. Each new person infects R0 new people, except that some of them are already immune. The percentage who are not immune is 1-(1-1/R0)==1/R0, so each diseased person infects R0*(1/R0)==1. So this is the level of immunity at which the chain reaction begins to fizzle - above this level, each person is infecting fewer than one new person, below it, each person is infecting more.

This I got almost as soon as I saw the 1-1/R0 expression. But, it seems to me this is not the level at which the disease dies out; it is the level at which it begins to decline. I am trying to work this out, and confirm my intuition.

Arneb wrote:Interstingly, it explains why we never totally get rid of measles. it has an R0 of around 15, so for the disease to die out as a result of herd immunity you need an immunization rate of more than 93 %. We don't get that high because, as they say in Italy, the mother of all idiots is always pregnant.


Wow. Highly contagious. (At least, I think that's highly contagious. Maybe some diseases have more.)

I had a thought on how to remedy a possibly serious defect in my model, which is the cumulative infection rate going over 100%. If 1% infection rate results in R0% new infection rate, then 2% infection rate results in (2R0-R0^2)% new infections. It doesn't just double, becomes some of the people infected by the first 1% and those by the second 1% will be the same people. So that results in one new infection, not two. Continuing in this way, if 3% are infected, they should infect (3R0-3R0^2+R0^3)%. So the number of new infections should be related to the binomial expansion of (1-R0)^p, where p is the percentage of the people infected. Dividing the population into blocks smaller and smaller than 1% and repeating the analysis, it looks like the percentage of new infections should be related to an exponential function. I will try to work out the details on the bus.
They call me Mr Celsius!
User avatar
Мастер
Moderator
Moderator
Злой Мудак
Mauerspecht
 
Posts: 23935
Joined: Tue Aug 02, 2005 2:56 pm
Location: Far from Damascus

Re: Pandemic Modelling

Postby Lance » Thu Apr 02, 2020 7:05 am

Мастер wrote:I will try to work out the details on the bus.

You're taking a fucking BUS??? Is that wise right now?
No trees were killed in the posting of this message.
However, a large number of electrons were terribly inconvenienced.

==========================================

Build a man a fire and he will be warm for a few hours.
Set a man on fire and he will be warm for the rest of his life.
User avatar
Lance
Administrator
Administrator
Cheeseburger Swilling Lard-Ass who needs to put down the remote and get off the couch.
 
Posts: 91419
Joined: Thu May 12, 2005 5:51 pm
Location: Oswego, IL

Re: Pandemic Modelling

Postby Мастер » Thu Apr 02, 2020 7:17 am

Lance wrote:
Мастер wrote:I will try to work out the details on the bus.

You're taking a fucking BUS??? Is that wise right now?


I think things are a lot more under control here than there.

For what it’s worth, I was the only passenger on the double-decker bus for the entire journey.
They call me Mr Celsius!
User avatar
Мастер
Moderator
Moderator
Злой Мудак
Mauerspecht
 
Posts: 23935
Joined: Tue Aug 02, 2005 2:56 pm
Location: Far from Damascus

Re: Pandemic Modelling

Postby Мастер » Thu Apr 02, 2020 7:41 am

Arneb wrote:I heard a mathematical biologist in a podcast yesterday saying that the proportion of not-susceptible people you need in a population to achieve herd immunity (and conversely, the proprortion of members in a population that a new pathogen will typiclcally infect before it dies out) is relatively easy to compute: It comes down to 1 minus the inverse of the basic reproduction number (R0; the average number of other members of the population someoe infects before becoming-non-infectious).


I am okay with the interpretation of this number as the amount you need for “herd immunity”. I am having a lot of trouble getting to the second interpretation (the one in parenthesis.)

I am thinking that this is the steady state long-term infection rate. But that it can go higher for a while.

My model is missing births, introduction of new non-immune people into the population. Without births, I’m getting that every disease eventually dies out. So having births seems like it is important, at least for long-term modelling. I don’t think it is important for short-term modelling.
They call me Mr Celsius!
User avatar
Мастер
Moderator
Moderator
Злой Мудак
Mauerspecht
 
Posts: 23935
Joined: Tue Aug 02, 2005 2:56 pm
Location: Far from Damascus

Re: Pandemic Modelling

Postby Arneb » Thu Apr 02, 2020 8:32 am

Of course, the "conversion" that I put into parenthesis depends on the actual properties of the pathogen. In the case of Corona, the underlying assumptions are that everyone who was infected once cannot be infected again for the duration of the model, that incubation time is short in comparison to the running time of the model, and that the pathogen does not mutate so that immunity once acquired is voided. Then the pathogen indeed will die out at the threshold for herd immunity (that's nicely demonstrated in the second 3blue1brown video), and not circulate.

Things like waning immunity due to genetic drift or inherently non-permanent types of protective immunity (as with influenza, a lot of the common cold viruses including common Corona viruses and, possibly, with our new Corona virus), latent infection (as with TB, HIV, certain malaria types), infection into a different reservoir (as with influenza or bubonic plague), long-term survival in the environment without ongoing infection (as for anthrax) are not accounted for.

For what it's worth, the podcast with the mathematical biologist is here: https://www.youtube.com/watch?time_cont ... e=emb_logo
Non sunt multiplicanda entia praeter necessitatem
User avatar
Arneb
Moderator
Moderator
German Medical Dude
God of All Things IT
 
Posts: 70075
Joined: Thu Nov 23, 2006 8:22 pm
Location: Potsdam, Germany

Re: Pandemic Modelling

Postby Мастер » Thu Apr 02, 2020 9:22 am

Arneb wrote:the underlying assumptions are that everyone who was infected once cannot be infected again for the duration of the model


OK.

Arneb wrote:that incubation time is short in comparison to the running time of the model,


I'm doing this in "rounds", where you have the disease for one round, you expose R_0 other people, who will develop the disease next round, if they are not immune. Then in my magical spreadsheet technology, I just run it until the disease has died out, and the cumulative infection rate has reached its maximum.

So I guess I am meeting that assumption.

Arneb wrote:and that the pathogen does not mutate so that immunity once acquired is voided.


Check.

Arneb wrote:Then the pathogen indeed will die out at the threshold for herd immunity


I've repaired my broken model, which counted a person exposed simultaneously to two carriers as two new infections. That was what allowed my cumulative infection rate to go above 100%. Fixed now.

But, I am still not getting this result. Here are my revised numbers.

If r0=1.1, the pandemic reaches its peak on period 78, with about 0.427% of the population infected. By this time, 9.18% of the population has been infected, but ultimately the cumulative infection rate will be 17.62%. (Almost no change from my earlier, broken model, results.)

If r0=1.5, the pandemic reaches its peak on period 25, with about 6.29% of the population infected. By this time, 34.59% of the population has been infected, but ultimately the cumulative infection rate will be 58.28%. (Somewhat modest changes from my earlier, broken model, results.)

If r0=2.0, the pandemic reaches its peak on period 16, with about 15.18% of the population infected. By this time, 53.91% of the population has been infected, but ultimately the cumulative infection rate will be 79.68%. (Substantial changes from my earlier, broken model, results.)

If r0=3.0, the pandemic reaches its peak on period 10, with about 27.34% of the population infected. By this time, 51.36% of the population has been infected, but ultimately the cumulative infection rate will be 94.05%. (Very substantial changes from my earlier, broken model, results.)

In all cases, I am getting cumulative infection rates well above the 1-1/R0 threshold for herd immunity.

What I do get is that the 1-1/r0 threshold is where the pandemic peaks - not where it dies off. It keeps going for a while yet.

Arneb wrote:(that's nicely demonstrated in the second 3blue1brown video), and not circulate.


I haven't looked yet, because I wanted to work it out on my own. I will have a look. But the possibilities, if we are reaching different conclusions, are:

a) One or both of us is making a mistake in the analysis.

b) We are using different assumptions.

The areas where I think my model would be subject to criticism are:

a) Synchronous nature - everything is done in rounds. There is a time to catch the disease, a time to spread it, and a time to be cured. In reality, everyone is running according to their own clock.

b) Random exposure - the people you come in contact with are randomly selected from the population. This does not generate clusters. In reality, there are clusters, because people are already clustered - if two people know me, odds are much higher that they know each other, than the odds that two randomly selected members of the population know each other.

c) Static population - there are no births (so I guess all brand new people are born without immunity?), and no deaths, even from the disease. Presumably births raise the percentage of people who are not immune, and so do deaths from the disease (relative to my model, which says someone who catches the disease remains in the population immune, rather than leaving the population through death).

d) Anything else?

So I should have a look, because I am getting that the threshold for herd immunity is where the disease peaks, not where it dies out.

Arneb wrote:Things like waning immunity due to genetic drift or inherently non-permanent types of protective immunity (as with influenza, a lot of the common cold viruses including common Corona viruses and, possibly, with our new Corona virus), latent infection (as with TB, HIV, certain malaria types), infection into a different reservoir (as with influenza or bubonic plague), long-term survival in the environment without ongoing infection (as for anthrax) are not accounted for.


Nor in my model.

Arneb wrote:For what it's worth, the podcast with the mathematical biologist is here: https://www.youtube.com/watch?time_cont ... e=emb_logo


Can have a look as well.
They call me Mr Celsius!
User avatar
Мастер
Moderator
Moderator
Злой Мудак
Mauerspecht
 
Posts: 23935
Joined: Tue Aug 02, 2005 2:56 pm
Location: Far from Damascus

Re: Pandemic Modelling

Postby Arneb » Thu Apr 02, 2020 2:29 pm

I thinkt the most probable explanation explanation is that I misheard what the mathematician said. Maybe he said, the 1- 1/R_0 thershold is when the pathogen starts to die out.

I hope I get this correctly: R_0 is the propagation rate at the beginning of the epidemic, with an unlimitied supply of susceptible hosts and enough time to complete the number of infection inherent in the pathogen's ands hosts' biologiy. The actual rate R_t is a dependent variable after that, right? Maybe 1-1/R_0 is when R drops below 1 simply for lack of susceptible hosts.

Whenever you and I come to different conclusions about anything, absolutely anything, mathematical, my default assumption is I am wrong.
Non sunt multiplicanda entia praeter necessitatem
User avatar
Arneb
Moderator
Moderator
German Medical Dude
God of All Things IT
 
Posts: 70075
Joined: Thu Nov 23, 2006 8:22 pm
Location: Potsdam, Germany

Re: Pandemic Modelling

Postby Мастер » Thu Apr 02, 2020 4:36 pm

Arneb wrote:I thinkt the most probable explanation explanation is that I misheard what the mathematician said.


Well, let me have a listen, and see what I hear. Or hear what I hear, I guess.

Arneb wrote:Maybe he said, the 1- 1/R_0 thershold is when the pathogen starts to die out.


That's what I'm getting. The number of currently infected people starts to decline around this level. (For the initial outbreak, I think there is also an approximation involved in derivation fo the 1-1/R_0 number.) However, the cumulative infection rate goes above 1-1/R_0. It might start to decline, but I need to add births to my model to get that.

Arneb wrote:I hope I get this correctly: R_0 is the propagation rate at the beginning of the epidemic, with an unlimitied supply of susceptible hosts and enough time to complete the number of infection inherent in the pathogen's ands hosts' biologiy.


I think so. At least, that's the way I'm interpreting it.

Arneb wrote:The actual rate R_t is a dependent variable after that, right? Maybe 1-1/R_0 is when R drops below 1 simply for lack of susceptible hosts.


Well, if we say each person exposes R_0 other people, but percentage (1-1/R_0) are already immune, then R_0*(1-1/R_0)=R_0-1 do not catch the disease. So you expose R_0 people, but R_0-1 are already immune, so you only infect one new person. So yes, 1-1/R_0 appears to be the level at which each infected person creates one new infection.

Well, sort of. That would be true when the number of currently infected people is very low. If the number of currently infected people is large, then some of their new infections will be the same people. I assume exposing a non-immune person to two carriers has the same effect as exposing them to one. So a lot of people are currently infected, then the one infected person begets one new infected person logic is double counting some new infections.

In my model, there is no birth, and every disease eventually dies out. But if there is birth, that is a constant introduction of new people who can be infected. If that happens, my gut feel is, the disease will rage out of control, initially reaching a cumulative infection rate of more than 1-1/R_0. It will then start to decline, dropping back down to this level - new people are being born, and infection is now rare, but greater than zero. When it reaches (from above) the 1-1/R_0 threshold, then some of the new births get infected (and probably some of the existing population which was never infected), and the cumulative infection rate stays at the 1-1/R_0 threshold steady state. But I emphasise that, at this point, this is my gut feel - there is no hard analysis behind this conclusion yet.
They call me Mr Celsius!
User avatar
Мастер
Moderator
Moderator
Злой Мудак
Mauerspecht
 
Posts: 23935
Joined: Tue Aug 02, 2005 2:56 pm
Location: Far from Damascus

Re: Pandemic Modelling

Postby tubeswell » Sat Apr 04, 2020 12:49 am

Arneb wrote: as they say in Italy, the mother of all idiots is always pregnant.


I'm borrowing this - it sums up my mother nicely
A bus station is where a bus stops. A train station is where a train stops. On my desk, I have a work station.

If you are seeing an apparent paradox, that means you are missing something.
User avatar
tubeswell
Enlightened One
Enlightened One
 
Posts: 324866
Joined: Sun Sep 19, 2010 11:51 am
Location: 129th in-line to the Llama Throne (after the last purge)

Re: Pandemic Modelling

Postby Мастер » Thu Mar 18, 2021 8:58 am

Simple-minded modelling.

Go in rounds. Each round, you get the disease, or you don't. If you get the disease, you become immune for the following rounds.

R_0 is the number of people exposed to the disease by each infected person.

Now, if R_0 is less than one, a disease tends to die out. Each round, fewer people are infected, until it eventually approaches zero people infected. But, that doesn't mean the number of people infected is not large.

If we start with a very large population, and one person is infected, then the total number of people ever infected is 1/(1-R_0).

So if R_0 is close to but less than one, the disease does die out, but a huge number of people can still get it.

For example, if R_0 is 0.99, then each infected person today results in a total of 100 persons (including the original carrier) being infected now and in the future. If R_0 is 0.9999, then it is 10,000 people.

So for practical purposes, you don't just want R_0 to be less than 1, you want it to be not super close to one. If it is 0.8, then five people in total are infected from each person infected today (the total of five including the originally infected person).

Immunity - suppose percentage X of the population is immune. So if you are sick, and you cough all over someone, there is a chance (1-X) that they get the disease, and chance X that they don't. Then your R_0 exposures result in (1-X)*R_0 new infections, and the important thing is, is (1-X)*R_0 less than one?

Well, writing that down as an inequality and then solving for X, we get that X being greater than 1-1/R_0 does the trick. I think we have seen that before.

But, we need to interpret it correctly. This means that the disease eventually dies out. It doesn't mean that a lot of people don't get infected.

As an example, suppose we start with 1% of the population infected in round zero. The R_0 is 2.5. The herd immunity threshold is 0.6. However, this does not mean that only 0.6 of the people will get infected.

About 98.146% of people will be infected, a number far above the immunity threshold.

What happens? Herd immunity is achieved after only six rounds. At this point, 82.200% have been infected, well above the threshold. But, this means that the disease is now in decline - each person infects fewer than one - they expose 2.5, but more than 60% are immune, so their 2.5 exposures results in less than one new infection. So the disease is now dying out. But it takes a while to do so.

Eventually, more than 98% are infected. The doomed disease still hits a lot of people while it is in decline.

With an initial 0.1% infected, and an R_0 of 3.0, the disease eventually infects 100.030% of the population.

Why this nonsensical result? Because there is some double-counting. Each infected person exposes 3.0 new people, with some probability X (which changes over time) that they are immune. So each person infects (1-X)*3.0 new people. But, some people will be "infected" twice (or more), by different currently infected people.

Solution - need to model the number of new infections using the hypergeometric probability distribution, which would account for the double (or triple, or quadruple, etc.) counting. What a right royal pain in the arse. Too much for a Central European boy trying to blend in in an Irish tavern the day after St. Patrick's Day. Maybe some other time.
They call me Mr Celsius!
User avatar
Мастер
Moderator
Moderator
Злой Мудак
Mauerspecht
 
Posts: 23935
Joined: Tue Aug 02, 2005 2:56 pm
Location: Far from Damascus


Return to Science and Technology

Who is online

Users browsing this forum: No registered users and 2 guests

cron