Replies: 3 comments 2 replies
-
Quick note re:
I think there are likely some opportunities here to show that systems like SIR+V can be approached instead in terms of stratification on intervention status. |
Beta Was this translation helpful? Give feedback.
-
Meeting 29/08/2024 - Carl & TijsLatest version generalization FOI: FlepiMoP_3_0.pdf Powerpoint with meeting summary: n_dimensional_compartmental_models.pptx |
Beta Was this translation helpful? Give feedback.
-
@alsnhll: expressive languages for chemical reaction networks are very similar to epidemics: https://kappalanguage.org |
Beta Was this translation helpful? Give feedback.
-
After bouncing of an interesting chat with @pearsonca about flepimop's future, I'm proud to say I finally understand the force-of-infection in compartmental models with$n$ strata, where each strata has a 2D within-dimension interaction matrix and across-dimension broadcasts. I hope it may serve as a mathematical and computational blueprint for FlepiMoP 3.0 and spark discussion, and I hope you enjoy this read.
Force of infection in$n$ dimensions
For a model with$n$ strata labeled $k: 1 \to n$ , where every strata's interactions are captured by a 2D interaction matrix $N^k_{i_k j_k}$ , which can be broadcast across any combination of the remaining $n-1$ dimensions by means of a broadcasting tensor $B^k$ (dimensionality can range from 0 to $n-1$ ), to obtain an $n+1$ dimensional interaction tensor $N^k_{i_1 j_1 i_2 \cdots i_n}$ , a unified contact tensor $C_{i_1 j_1, \cdots, i_n, j_n}$ can be defined as follows,
and,
Because the position of the broadcasting tensor in the expanded product does not matter, the unified contact tensor can be written as,
For some reason these three terms above don't want to fit on one line but use your imagination. In this equation the terms$N$ represent the within-dimension interactions, and the terms $B$ represent the across-dimension broadcasts of $N$ . Using the unified contact tensor the force of infection can be neatly written as,
the coolest thing is how easily this can be implemented in the computer using Einstein summation (for the sake of brevity omitting any broadcasting B),
Using$\mathbf{s}$ and $\mathbf{r}$ to group the multi-dimensional indices representing the different stratifications,
which is consistent with the one-dimensional specification commonly found in textbooks (see f.i. Keeling and Rohani p.238).
Two-dimensional example: age and space stratification
Assuming there are no broadcasts of the social contact matrix$N_{ab}$ and the mobility matrix $M_{cd}$ . The unified contact tensor can be constructed to accommodate individuals having a fraction $f_v$ of their contacts on their visited patch, while having $(1-f_v)$ contacts on their home patch (a commonly used way to incorporate temporary human movement as a driver of infectious disease; see f.i. Keeling & Rohani section 7.2.1.4),
by exploiting Kronecker delta (equivalent to identity matrix for this case) as a "mobility matrix of people staying". If$f_v = 1$ , individuals make all their contacts on visited patches. The force of infection for an SIR model using the unified contact tensor is,
Which is coded up neatly using
np.einsum
,and yields the same results as the reference model used in the other discussion, for an epidemic seeded in municipality Aarlen,
Adding broadcasting
To incorporate the scenario where the mobility matrix is different for individuals of different ages in both the home patch and visited patch, we introduce a 1D vector$\alpha_a$ that scales the mobility matrix for each age group $a$ . The unified contact tensor for this case becomes,
and is again coded up rather neatly using
np.einsum
,whose implementation as$\alpha_a=1$ does not alter the simulation, while for $\alpha_a=0$ there is no mobility. The position of $\alpha_a$ in the Einstein summation does not alter the results, further highlighting the syntax' flexibility,
is equivalent to,
Three dimensions
Extending this age- and space stratified model (without above broadcast) with an additional stratification representing race, with racial segregation modeled using a two-dimensional racial segregation matrix$\mathbf{R}$ is straightforward (have to computationally test). Mathematically, the unified contact tensor becomes,
and the force of infection is,
Homogeneous mixing among races can implemented by making$\mathbf{R}$ a matrix full of ones, while perfect racial segregation is implemented using the identity matrix. Another example highlighted by Carl is implementing vaccines in this way, where the interaction matrix $\mathbf{V}$ could be used to represent clustering of people who do and don't get vaccinated.
Computational complexity
The above simulation has 3 disease states, 581 spatial patches, 4 age groups resulting in 6972 compartments, simulated over 120 days using scipy's RK45 using a 2024 MacBook Pro M3 Max.
np.einsum
the simulation takes 3.6 s and 4.0 s without and with broadcasting respectively.Implications
np.einsum
function.Beta Was this translation helpful? Give feedback.
All reactions