Open twallema opened 1 month ago
Confirming that this issue is fixed by adding two pairs of brackets around the summed compartments "I1" and "I2", i.e. changing,
transitions:
- source: ["S"]
destination: ["I1"]
rate: ["beta"]
proportional_to: ["source", ["I1","I2"]]
proportion_exponent: ["1", "1"]
into,
transitions:
- source: ["S"]
destination: ["I1"]
rate: ["beta"]
proportional_to: ["source", [[["I1","I2"]]]]
proportion_exponent: ["1", "1"]
yields,
Further crossreffing issues #298 and #301 for this model,
- source: ["I1"]
destination: ["I2"]
rate: ["2/T_I"]
proportional_to: ["I1"] # --> will not work; must be equal to "source": disease states with length > 1 in `proportional_to` get cut off by gempyor.
proportion_exponent: ["1"]
@saraloo To reiterate for anyone following along - the brackets should be (this syntax is so confusing to describe haha but hopefully/maybe this makes sense??):
proportional_to:
[
[source rates],
[destination rates]
]
breaks down into
proportional_to:
[
[source rates],
[[level of stratification defined in compartments]]
]
breaking down again into
proportional_to:
[
[source rates],
[[[sum over these compartments within that stratification]]]
]
and the rule that brackets are required if there is no broadcasting, but no brackets if rates are broadcast, applies here (this is probably very confusing but tldr; there should be 3 levels of brackets if summing within a compartment stratification level, even if there is just the one comparment stratification level)
Label
bug, gempyor, invalid
Priority Label
high priority
Describe the bug/issue
Specifying a transition proportional to a sum of states
To specify a transition from disease state 'X1' --> 'X2' proportional to the source and a sum of states 'Y1' and 'Y2', the following syntax can be placed in the config files,
This syntax is useful in the FOI, for instance
X1 = S
,X2 = E
,Y1 = I
andY2 = I_v
(vaccination as a disease state).See: https://iddynamics.gitbook.io/flepimop/gempyor/model-implementation/compartmental-model-structure
Testing the syntax
SIR model
Just your regular ol' SIR model with
beta = 0.75
andgamma = 1/T_I = 1/5 = 0.2
, resulting inR0 = 3.75
. I used 333M inhabitants, of which 1000 infected and 1 recovered individual as the initial condition. The expected final epidemic sizeR_{inf}
for an SIR model with anR0 = 3.75
is equal to 97.4%.with
initial_conditions_SIR.py
,SI2R model
We contrast the SIR model with an SI2R model, where we apply the linear chain trick to the I compartment. The SI2R model differs from the SIR by splitting the
I
inI1
andI2
compartments with half the residence time as compared to the SIR'sI
compartment in each (2*gamma=0.4
). BothI1
andI2
can infect theS
with equal probabilitybeta
. I used 333M inhabitants, of which 500 in I1 and 500 in I2, along with 1 recovered individual as the initial condition. These models should have an identical outcome in a deterministic simulation, as only the distribution of the residence time in the I = I1 + I2 compartments are altered, and not the expected residence time. The FOI for this model is,Implemented as (transitions only),
Results
Top: Simulation of the SIR model; behavior is as expected. Dashed black line: expected final epidemic size in an SIR model for
R0 = 3.75
.Bottom: Simulation of the SI2R model; behavior not as expected. Dashed black line: expected final epidemic size in an SIR model for
R0 = 3.75
. Dotted black line: expected final epidemic size in an SIR model forR0 = 0.5*3.75
.The SI2R model behaving as if the reproduction number is half of what is supposed to be as a clear indication that the FOI is computed as,
or,
instead of,
Are there any obvious mistakes in the config files? If not, we'll have to address this.
To Reproduce
reproduce_error.zip
Environment, if relevant
Mac OS, FLEPIMOP-ENV, main GitHub branch