Skip to content

The Modelica epidemiological model is wrong #117

@mbaudin47

Description

@mbaudin47

The epidemiological model implemented in epid.mo is wrong. Indeed the simplest SIR equations are (see 1 page 455):

$$ \begin{aligned} &\dfrac{dS}{dt} = -\beta \dfrac{SI}{N}\\ &\dfrac{dI}{dt} = \beta \dfrac{SI}{N} - \gamma I\\ &\dfrac{dR}{dt} = \gamma I \end{aligned} $$

But the equation for $\frac{dS}{dt}$ is implemented as:

der(susceptible) = - infection_rate*infected*susceptible;

The significant fact is that the right hand side of the ODE in the model does involve N: the model uses infection_rate * infected * susceptible (i.e. $\beta SI$) instead of infection_rate * infected * susceptible / total_pop (i.e. $\beta SI / N$). This is wrong because it is not consistent with the initial number of infected $I(0)$ which is set to 1:

infected = 1;

Actually, there are two different consistent choices.

  • We set the total population $N$ to 1. In this case, S, I and R represent the fraction of the population in each compartment. Under this hypothesis, the initial number of infected is set to $I(0) = \frac{1}{N}$ and $S(0) = 1 - I(0)$. In this case, the line 13 of the model is wrong and the expression for der(susceptible), der(infected) and der(removed) in the .mo file is correct.
  • We use the actual total population. In this case, we must divide by $N$. Under this hypothesis, the expression for der(susceptible), der(infected) and der(removed) in the current .mo file is wrong. This is the choice consistent with 2 figure 2 page 18 (the error must have been introduced later, because the Modelica model presented in 2 page 16 is correct).

The consequence of the bug is the the beta variable does not have the value it should: the current code uses $\beta / N$ where it should use $\beta$. Hence, the basic reproduction number $R_0 = \beta / \gamma$ is wrong. It is currently close to 0.005456, which is much smaller than the expected value of influenza. The correct value should be close to 4.163, i.e. 763 times much larger.

All in all, I suggest to use the following model, where the parameters are the infectious period (which is 1 / gamma) and the reproduction number (R0 = beta / gamma). These parameters are much easier to interpret and standard in the bibliography. Below, I use the parameters found in 1 figure 1 page 455. This leads to beta = 0.2143 (infection rate) and gamma = 1.0 / 14 = 0.07143 (healing rate).

model epid

parameter Real total_pop = 1000.0;
parameter Real healing_rate = 0.07143;
parameter Real infection_rate = 0.2143;

Real infected;
Real susceptible;
Real removed;

initial equation
infected = 1;
removed = 0;
total_pop = infected + susceptible + removed;

equation
der(susceptible) = - infection_rate * infected * susceptible / total_pop;
der(infected) = infection_rate * infected * susceptible / total_pop - healing_rate * infected;
der(removed) = healing_rate * infected;

annotation(
    experiment(StartTime = 0.0, StopTime = 200.0, Tolerance = 1e-6, Interval = 0.1));
end epid;

When we simulate the model, we can compare to the results found at https://shiny.bcgsc.ca/posepi1/.

If we want to reproduce the results from 2, we may use the following settings, obtained after calibrating from the data found in 3 using non linear least squares, and rounded to 1 significant digits (I believe that the extra digits are not accurate, given the uncertainties in the data):

parameter Real total_pop = 763.0;
parameter Real healing_rate = 0.5;
parameter Real infection_rate = 2.0;

Updating these model will require to update the .fmu for Linux and Windows platforms available in the FMU directory.

Footnotes

  1. Bjørnstad, O. N., Shea, K., Krzywinski, M., & Altman, N. (2020). Modeling infectious epidemics. Nature methods, 17(5), 455-457. 2

  2. S. Girard, “A probabilistic take on system modeling with Modelica and Python”, Février 2019, https://sylvaingirard.net/pdf/girard17-probabilistic_modelica_python.pdf 2 3

  3. Anonymous (1978). ‘Influenza in a boarding school’. In: British Medical Journal 587.1. url: http://www.ncbi.nlm.nih.gov/pmc/articles/PMC1603269/?page=2.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions