springer-math / Mathematics-of-Epidemics-on-Networks

Source code accompanying 'Mathematics of Epidemics on Networks' by Kiss, Miller, and Simon http://www.springer.com/us/book/9783319508047 . Documentation for the software package is at https://epidemicsonnetworks.readthedocs.io/en/latest/
MIT License
151 stars 61 forks source link

What is the unit of time? #58

Closed crinix16 closed 4 years ago

crinix16 commented 4 years ago

Dear Miller, I am a MSc student from Bogazici University CS program. As you have previously suggested, I am using fast_SIR with transmission_weight as edge weights to run SIR on weighted networks.

I tried it with graphs of different sizes and came across an odd result with time t. When I tried it with a network of 6 vertices, last value in t[] array, t[-1] was 3ish and when I ran it with thousands of vertices, of similar transmission weights, it resulted in a t[-1] value around 1. This is odd because as I see it, it should have been something like 3ish * 1000 = 3000.

So my question is, what is the time unit and how does it work? (for different models maybe? I am using fast_SIR.) Because according to these two experiments of my own, there seems to exist some scaling(?) factors.

Thank you.

joelmiller commented 4 years ago

Hi,

I wouldn't expect it to be as big as 3000 (epidemic duration is roughly proportional to the logarithm of the population size), but you're right that if an epidemic occurs it would last quite a bit longer.

What I suspect is happening is that the simulation you are looking at isn't having an epidemic. This might be because the parameters are below the epidemic threshold, or that the specific simulation happened to die out stochastically.

You can plot I versus t to see whether an epidemic happened (or take a quick look at R[-1]). If you never see an epidemic, then you're probably below the epidemic threshold. Increasing the transmission rate would probably change this.

crinix16 commented 4 years ago

Thank you for answer. OK I guess I should have said that my gamma is 0 at the moment so I am basically running an SI model until I complete my code.

I just ran a fast_SIR on a connected network of 3500 vertices, with EoN.fast_SIR(G, tau = 1, gamma = 0, transmission_weight = 'weight', initial_infecteds = 0, return_full_data = True).

Simulation ended in t[-1] = 1.261. I checked whether everyone in the Graph was infected, using sim.get_statuses(G.nodes, sim.t()[-1] and yes every vertex was I in t[-1].

Then I ran the same model with a complete network of only 5 vertices, it took 2.033 time units. Again I checked whether every node was infected using get_statuses() function for last t value, and yes they were infected.

Therefore, in this circumstance I don't know how to interpret the results. I don't know why and how time value is not discrete either.

joelmiller commented 4 years ago

Can you tell me what the graphs were and exactly what the arguments to fast_SIR were?

Also - I'm not clear on what you're expecting about the time value being discrete. Can you say a bit more?

crinix16 commented 4 years ago

First graph: Connected graph of 3500 vertices, with edge weights being $\beta$, $\beta^{2}$ and $\beta^{3}$ depending on vertices, where $\beta = 0.5$

Second graph: Complete graph of 5 vertices with edge weights $\beta = 0.5$.

fast_SIR configuration is as below: EoN.fast_SIR(G, tau = 1, gamma = 0, transmission_weight = 'weight', initial_infecteds = 0, return_full_data = True)

For reasons above, it's trivial to expect a much more smaller t value for second graph and much bigger t value for the first.

I can share the graph objects as pickle, too, if you ask.

What am I doing/interpreting wrong? Thank you.

joelmiller commented 4 years ago

My one thought is that the typical degree may be much higher in the larger graph, so it's able to spread much faster

crinix16 commented 4 years ago

OK I will investigate this furthermore and share the result here. To clearify the main question, what is the unit of time and how does it work?

My question about discrete-ness was related to counting an integer in for loop for every time iterating over infected nodes, whether they will spread the disease with probability beta. This way it'd be a discrete number, like 1500. But our t values are continuous. So how does it work/count the t value?

Thank you.

joelmiller commented 4 years ago

So this algorithm is for continuous time. It assumes individuals transmit with a rate (tau). This means that the transmission (or recovery) can occur at any time. The probability of a transmission along an edge in a short period Delta t is approximately tau Delta t if Delta t is small.