Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dcm ngm primer #53

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
106 changes: 106 additions & 0 deletions docs/primer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
# A Primer on Next Generation Matrix Models

A Next Generation Matrix model is a way to model the expected number of infections generated by a typical infected individual in different groups or categories of the population in consecutive generations. The Next Generation Matrix (here after referred to as the NGM) encodes this information. NGM models are an effective way to model average dynamics in a heterogeneous population during the early growth phase and in the limit of the disease-free equilibrium.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
A Next Generation Matrix model is a way to model the expected number of infections generated by a typical infected individual in different groups or categories of the population in consecutive generations. The Next Generation Matrix (here after referred to as the NGM) encodes this information. NGM models are an effective way to model average dynamics in a heterogeneous population during the early growth phase and in the limit of the disease-free equilibrium.
A Next Generation Matrix model is a way to model the expected number of infections generated by a typical infected individual in different groups or categories of the population in consecutive generations. The Next Generation Matrix (hereafter referred to as the NGM) encodes this information. NGM models are an effective way to model average dynamics in a heterogeneous population during the early growth phase and in the limit of the disease-free equilibrium.


An NGM model is related to the branching process concept of an offspring distribution generated by an individual. In this context, the NGM represents the expected value of the offspring distribution, or in this case, the distribution of infections caused in a group from a typical infectious individual in another group.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I follow the expected value bit (each column is the expected count of infections from one individual in one category into all groups), but I don't get "in this case the distribution of infections" bit. To me, the "distribution" would be normalized (sum to one).


Some classic works on NGMs are:

Diekmann, O., Heesterbeek, J.A.P. & Metz, J.A.J. On the definition and the computation of the basic reproduction ratio R 0 in models for infectious diseases in heterogeneous populations. J. Math. Biol. 28, 365–382 (1990). https://doi.org/10.1007/BF00178324

Diekmann O, Heesterbeek JA, Roberts MG. The construction of next-generation matrices for compartmental epidemic models. J R Soc Interface. 2010 Jun 6;7(47):873-85. https://doi.org/10.1098/rsif.2009.0386. Epub 2009 Nov 5. PMID: 19892718; PMCID: PMC2871801.

van den Driessche P, Watmough J. Reproduction numbers and sub-threshold endemic equilibria for compartmental models of disease transmission. Math Biosci. 2002 Nov-Dec;180:29-48. doi: https://doi.org/10.1016/s0025-5564(02)00108-6. PMID: 12387915.

This primer is meant to supplement these works and articulate how the NGM can be used in a transmission model in addition to being an analytical tool.

## Use of NGM as a model
Most commonly, NGMs are used in infectious disease modeling as an analytical tool to estimate the potential for growth of a disease in a population. NGMs are particularly useful for this when a population can be split into a finite number of discrete categories with different epidemiologically relevant traits. In that case, we can define the NGM and use it calculate the basic reproduction number $R_0$, a quantity that can provide insight about the early growth of a disease in a population and interventions that may be effective at controlling its growth. $R_0$ can be computed as the spectral radius of the NGM.

As a result, most modelers familiar with NGMs have experience with using them as an analytical tool rather than as a simulation tool. However, NGMs can also be used to approximately model the ODEs for the subsystem of infected states.

## Interpretation of matrix elements
Imagine we have an NGM, $\mathbf{R} = [R_{ij}]$. The elements $R_{ij}$ of this matrix can be interpreted as the average number of infections in group $i$ caused by an infected individual in group $j$ between consecutive generations in a fully susceptible population. As a rule of thumb, the matrix $\mathbf{R}$ is not symmetric; some groups may be more susceptible to infection or more transmissive resulting in an asymmetric \mathbf{R}.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm more used to seeing curly braces here (R = {R_ij})? But I can't seem to get GHFMD to render those, so, maybe that's why they're square? Note that GHFMD can't render mathbf either.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am realizing now that I am actually kind of confused about the relationship this "the NGM is just R" approach and the "get an NGM from a compartmental model" approach.

The distinction between the two matrices below of small and large domain makes me think that we can only do this for models where there is only a single state at infection for each group. While that's true of the models that come to mind readily, is it guaranteed to be true of all compartmental models with multiple groups? A quick survey produces the models in figure 6 here and figure 2f here which make me think not?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also: seems to assume only one compartment in downstream groups can cause new infections in other groups? Like, I'm having some trouble seeing how I would have to slice and dice the model to think this way about a multi-group model which distinguishes between symptomatic and asymptomatic cases.

Copy link
Contributor

@swo swo Jan 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dinacmistry I think this is an interesting scope question. I think it's useful to have a document that explains what an NGM is, and shows that it's something that can be either asserted & analyzed OR derived from ODEs. @afmagee42 's questions are valid, but I find it hard to imagine that a CFA project is going to include someone computing NGMs from a complex, multicompartment model.

Another way to say it is: my hypothesis is that: the Dieckmann et al. way of thinking is potentially useful for education/demonstration, but it's not the way CFA is actually going to produce or analyze any of its models. (This is where Dylan Morris would write "<ducks>")

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like there's a benefit of being able to understand it both ways. If one knows how an NGM comes out of a compartmental model, then it should be easier to see the limitations and assumptions that go into it from a perspective closer to that of a lot of epidemiologically-trained folks.

As it is right now I get it as a pure exponential growth branching process model, but if you asked me whether the behavior would be different between assuming new infections are immediately infectious or not, I couldn't tell you.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a good point: the "forward" way of thinking says "if I have a fixed NGM, then I'll necessarily get exponential growth" while the inference/analytical way of thinking says "I'll can the NGM that emerges from these equations, at a particular instant in time, and linearize around the DFE, to get an approximation of growth rate, knowing that the NGM will necessarily change in the next instant"

Only say that less confusingly

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Imagine we have an NGM, $\mathbf{R} = [R_{ij}]$. The elements $R_{ij}$ of this matrix can be interpreted as the average number of infections in group $i$ caused by an infected individual in group $j$ between consecutive generations in a fully susceptible population. As a rule of thumb, the matrix $\mathbf{R}$ is not symmetric; some groups may be more susceptible to infection or more transmissive resulting in an asymmetric \mathbf{R}.
Imagine we have an NGM, $\mathbf{R} = [R_{ij}]$. The elements $R_{ij}$ of this matrix can be interpreted as the average number of infections in group $i$ caused by an infected individual in group $j$ between consecutive generations in a fully susceptible population. As a rule of thumb, the matrix $\mathbf{R}$ is not symmetric; some groups may be more susceptible to infection or more transmissive resulting in an asymmetric $\mathbf{R}$.


## Conditions and limitations

Some conditions and limitations apply for NGM models to be a valid tool for estimating $R_0$ or as a simulation tool.

### Discrete states
The model population must be able to be divided into discrete compartments or states that are epidemiologically relevant. These strata may reflect heterogeneities in susceptibility, such as age, or health state, such as infectious and symptomatic vs. infectious and asymptomatic.

### The disease free equilibrium

The NGM is constructed by identifying transmission and transition dynamics of an infectious disease model near the disease-free equilibrium (DFE) and linearizing the system around that point.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm sure "linearize the compartmental model" makes perfect sense to many. But I get stuck between broad confusion and slightly-more specific "linear with respect to what" confusion every time. Is there a link, reference, or quick aside we could put in for that?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also feel obligated to complain that this is always (as in, everywhere I've seen, not something I'm blaming you for) discussed as "the DFE" instead of "the completely susceptible starting point." Feels like everyone's trying to pull a fast one over on me.


A disease-free equilibrium (DFE) is a point in the epidemiological system where the population is free of disease, i.e. at a DFE the infectious population is zero. There can be multiple DFE for a system; the NGM is defined for when the population is fully susceptible. For example, in the classic SIR model, there exists a DFE with the conditions ($S \approx N$, $I \approx 0$, $R = 0$), which leads us to the condition $R_0 = \frac{\beta}{\gamma} \geq 1 $ for growth of disease in the population when we linearize the system around that point. Another DFE exists at the point where ($S = 0$, $I = 0$, $R = N$), however this DFE is not epidemiologically relevant to disease dynamics since disease cannot grow in the population at this point.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
A disease-free equilibrium (DFE) is a point in the epidemiological system where the population is free of disease, i.e. at a DFE the infectious population is zero. There can be multiple DFE for a system; the NGM is defined for when the population is fully susceptible. For example, in the classic SIR model, there exists a DFE with the conditions ($S \approx N$, $I \approx 0$, $R = 0$), which leads us to the condition $R_0 = \frac{\beta}{\gamma} \geq 1 $ for growth of disease in the population when we linearize the system around that point. Another DFE exists at the point where ($S = 0$, $I = 0$, $R = N$), however this DFE is not epidemiologically relevant to disease dynamics since disease cannot grow in the population at this point.
A disease-free equilibrium (DFE) is an equilibrium in the epidemiological system where the population is free of disease, i.e. at a DFE the infectious population is zero. There can be multiple DFE for a system; the NGM is defined for when the population is fully susceptible. For example, in the classic SIR model, there exists a DFE with the conditions ($S \approx N$, $I \approx 0$, $R = 0$), which leads us to the condition $R_0 = \frac{\beta}{\gamma} \geq 1 $ for growth of disease in the population when we linearize the system around that point. Another DFE exists at the point where ($S = 0$, $I = 0$, $R = N$), however this DFE is not epidemiologically relevant to disease dynamics since disease cannot grow in the population at this point.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dumb question: why the \approxes?


### Depletion of susceptibles

NGM models describe infectious disease dynamics as a demographic process in the sense that each consecutive generation produces new offspring infections. This can be a good approximation for dynamics early on when the population can be roughly described as fully susceptible. However, unlike ODE models, an NGM model does not account for the fixed size of a population and cannot model the depletion of susceptibles over time.

### Other conditions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might want to mention population size -- that we expect these relationships to hold for large-ish populations that can be approximated with averages?

The NGM must be non-negative to guarantee that $R_0$ will be a single unique, positive real-valued eigenvalue of $\mathbf{R}$.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
The NGM must be non-negative to guarantee that $R_0$ will be a single unique, positive real-valued eigenvalue of $\mathbf{R}$.
Entries of the NGM must be non-negative to guarantee that $R_0$ will be a single unique, positive real-valued eigenvalue of $\mathbf{R}$.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pretty standard AFAIK that a non-negative matrix is one whose entries are non-negative.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But also, is that all that's required? My linear algebra is bad, but I thought that it was more complicated. (I don't know that this needs to be explained in-text, but I do think a reference/link would be nice for dummies like me.)


## Formal definition
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel that I am much closer to understanding what is going on with NGMs (as derived from compartmental models) than I was before, but I could use a little help getting the rest of the way.

  • I think I handwavily see why the large domain formulation (modulo the sign) is what it is: we're tracking flow into and out of the compartments, and it's got that (rate into I)/(rate out of I) sort of form
  • But we don't need to track everything, which is where K comes in
    • I don't quite get why this is just the states at infection we care about, I'd think the states at infectiousness would also enter into the picture?
    • There's a way to get this smaller matrix from the larger one by ignoring the unimportant bits, which is where E comes in, but I don't quite see in general how to formulate E. It's (# states at infection) x (# states), so we're doing some sort of mapping from the full $R_L$ down to just the states at infection as promised. But what mapping?
  • For the linear-algebraically challenged, is there handwavy intuition for why the spectral radius is $R_0$?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@afmagee42 re: last bullet, this is what I tried to do in #70 , to give some motivation there. (But there's a lot of material in #70 ; we might want some or none of it.)

For a system of differential equations describing infectious disease dynamics, we can identify the infected subsystem that describes the production of new infections and other changes in state of infected individuals. After linearizing around the DFE, we can decompose the infected subsystem into 2 parts representating rates of transmission and transition. It is common to see the transmission component referred to as $\mathbf{T}$, and the transition component referred to as $\mathbf{\Sigma}$. The Next Generation Matrix with Large domain is then defined as $\mathbf{R_L} = -\mathbf{T}\mathbf{\Sigma}^{-1}$.

The NGM $\mathbf{K}$ is the restriction of $\mathbf{R_L}$ to the subset of states-at-infection. An auxiliary matrix $\mathbf{E}$ can be defined whose columns are unit vectors for each non-zero row of the matrix $T$. The NGM can then be computed as $\mathbf{R} = -\mathbf{E}'\mathbf{T}\mathbf{\Sigma}^{-1}\mathbf{E}$, $\mathbf{E}'$ is the transpose of $\mathbf{E}$. It can be shown that the spectral radius of $\mathbf{R_L}$ is equal to that of $mathbf{R}$ and that this spectral radius is $R_0$.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
The NGM $\mathbf{K}$ is the restriction of $\mathbf{R_L}$ to the subset of states-at-infection. An auxiliary matrix $\mathbf{E}$ can be defined whose columns are unit vectors for each non-zero row of the matrix $T$. The NGM can then be computed as $\mathbf{R} = -\mathbf{E}'\mathbf{T}\mathbf{\Sigma}^{-1}\mathbf{E}$, $\mathbf{E}'$ is the transpose of $\mathbf{E}$. It can be shown that the spectral radius of $\mathbf{R_L}$ is equal to that of $mathbf{R}$ and that this spectral radius is $R_0$.
The NGM $\mathbf{K}$ is the restriction of $\mathbf{R_L}$ to the subset of states-at-infection. An auxiliary matrix $\mathbf{E}$ can be defined whose columns are unit vectors for each non-zero row of the matrix $\mathbf{T}$. The NGM can then be computed as $\mathbf{R} = -\mathbf{E}'\mathbf{T}\mathbf{\Sigma}^{-1}\mathbf{E}$, $\mathbf{E}'$ is the transpose of $\mathbf{E}$. It can be shown that the spectral radius of $\mathbf{R_L}$ is equal to that of $\mathbf{R}$ and that this spectral radius is $R_0$.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the relationship between the restricted K and R? It sounds like the R I was picturing above, made up of "one case in group j causes this many in group i" is K, because it's state-at-infection? Unless there are multiple possible states at infection...?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And can we say more about E? Surely I can't just plunk down any old values as long as the column sums are 1


In most cases, more intuitive approaches can be used to define the NGM, however the formal definition of $mathbf{R}$ has its advantages in being more rigorous and and helping modelers identify relevant information for estimating growth dynamics.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
In most cases, more intuitive approaches can be used to define the NGM, however the formal definition of $mathbf{R}$ has its advantages in being more rigorous and and helping modelers identify relevant information for estimating growth dynamics.
In most cases, more intuitive approaches can be used to define the NGM, however the formal definition of $\mathbf{R}$ has its advantages in being more rigorous and and helping modelers identify relevant information for estimating growth dynamics.


## A motivating example
The following is an example borrowed from Keeling & Rohani (2008, pp 57-63). Here, we go into depth of a modified version with additional insights from Diekmann et. al (2010) to arrive at the NGM model of the system.

Consider the scenario of a disease spreading in a population with two categories of individuals. These two groups are differentiated by their risk for acquiring infection; there is a high-risk (H) and a low-risk (L) group. The disease progression can be described using an SIR compartmental model. An NGM is an effective way of approximating the early disease dynamics for heterogeneous systems like this.

We denote the number of individuals in the high-risk group as $N_H$, and the number of individuals in the low-risk group as $N_L$. $X_H$ is the number of people in group $H$ who are in state $X$, and the total number of people in state $X$ = $X_H + X_L$. States in this model are $S$ for susceptible, $I$ for infected and infectious, and $R$ for recovered. Thus, we have $S_i + I_i + R_i = N_i$ for all subpopulations $i$ and $N = \sum_i N_i$ for a total fixed population size.

We also assume that average mixing holds for all individuals between the groups and within, i.e. no individual in either group has different contact rates than others in their group. Individuals in the two risk groups can interact with each other in some way such that an infectious individual would generate some number of new infections in the two groups. More specifically, an average infected individual in group $j$ generates $\beta_{ij}$ infections per unit time in group $i$ in a fully susceptible population.

Unlike the example in Keeling & Rohani, here we model the counts of the population in each state rather than the proportion. We are also modeling the effective rate of transmission between groups as split into two factors: a rate of transmission from group $j$ to group $i$, $\beta_{ij}$ and a rate of interaction based on the number of people in the population available for contact with infectious individuals, i.e. $\frac{S_i}{N}$. This follows from the frequency dependent assumption where effective contact structure that generates transmission is independent of population size (the interested reader can refer to Keeling & Rohani, 2008 pp 17-18 for more details).

At any given time, there is some fraction of the population that is susceptible in group $i$ and can be infected through interaction with an infected individual in group $j$. Then the average number of infections generated by this individual in group $i$ is $\frac{\beta_{ij}S_i}{N}$ per unit time. Assuming no collision of transmission events, $I_j$ infected individuals produce $\frac{\beta_{ij}S_i I_j}{N}$ infections per unit time.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"susceptible in group $i$ and can be infected through interaction with an infected individual in group $j$. Then the average number of infections generated by this individual in group $i$"

Are we sure this is right? This sounds like it's talking about a susceptible generating infections in its own group


Individuals in each risk group also recover from infection at some rate $\gamma_i$. Here we assume that individuals in both groups recover at the same rate, however the following can be generalized to scenarios where average recovery rates of the two groups are different.

Now we can write the infected subsystem of differential equations as

$\frac{d I_H}{dt} = \frac{\beta_{HH}S_H I_H}{N} + \frac{\beta_{HL}S_H I_L}{N} - \gamma I_H$

$\frac{d I_L}{dt} = \frac{\beta_{LH}S_L I_H}{N} + \frac{\beta_{LL}S_L I_L}{N} - \gamma I_L$

or more concisely as

$\frac{d I_i}{dt} = \sum_{j} \frac{\beta_{ij}S_i I_j}{N} - \gamma I_i$

From here we can decompose the system into transmission and transition components, $\mathbf{T}$ and $\mathbf{\Sigma}$, respectively.

Let
$\mathbf{x} =
\left(\begin{array}{cc}
I_H\\
I_L
\end{array}\right)$,
$\mathbf{T} = [T_{ij}]$ with $T_{ij} = \frac{\beta_{ij}N_i}{N}$, and $\mathbf{\Sigma} = \gamma \mathbb{1}$
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be Sigma = -gamma? Or is this why the equation above has R = -T Sigma?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Also I think that (sadly unrendered on GH) \mathbb{1} is intended to be a (similarly unrendered on GH) \mathbf{1}?)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like we should perhaps call attention to the substitution here of $S$ for $N$?

The reader has been warned it's coming (DFE and all that) but it's an important step.


Then we can write the infected subsystem as $\mathbf{\frac{dx}{dt}} = (\mathbf{T} + \mathbf{\Sigma})\mathbf{x}$. The NGM can be defined as

$R = -\mathbf{E}'\mathbf{T}\mathbf{\Sigma}^{-1}\mathbf{E}$.

For this system, the auxiliary matrix is
$\mathbf{E} =
\left(\begin{array}{cc}
1 & 0\\
0 & 1
\end{array}\right
)$
Comment on lines +91 to +97
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe you, but I don't know how to work it out for myself

with unit vector $\left(\begin{array}{cc}
1\\
0
\end{array}\right)$ for the state $I_H$ and unit vector $\left(\begin{array}{cc}
0\\
1
\end{array}\right)$ for the state $I_L$ in the transmission matrix $\mathbf{T}$.

Then the NGM can be defined as $\mathbf{R}$ with elements $R_{ij} = \frac{\beta_{ij}N_i}{\gamma N}$. This is the formulation used for the NGM model in this repository.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did we decided to generalize this NGM primer away from the widget? If not, it feels like there is a small disconnect between what they actually enter in the widget (which assumes population sizes have already been factored into the entries of the NGM) and this text. If we want to link this primer and the widget a bit more, we may want to show how vaccination gets factored into this (how proportion susceptible enters the calculation).

Suggested change
Then the NGM can be defined as $\mathbf{R}$ with elements $R_{ij} = \frac{\beta_{ij}N_i}{\gamma N}$. This is the formulation used for the NGM model in this repository.
Then the NGM can be defined as $\mathbf{R}$ with elements $R_{ij} = \frac{\beta_{ij}N_i}{\gamma N}$. This is the formulation used for the input NGM in the widget, noting the implicit assumption that the user has provided entries to the input NGM that factor in population sizes. Vaccination alters the proportion of susceptible individuals that may become infected in each group, thus the rows of the input NGM are multiplied by the remaining proportion susceptible after vaccination.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great suggestion, can add a section that speaks to the vaccination application too. I thought that the approach doc was sort of doing this already - what's something more fleshed out that you would want to see in the primer doc beyond what's in the approach doc?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right about the overlap here and I'm now recalling that this NGM primer was supposed to be more of a stand alone resource than the user guide and approach document and we had even discussed moving the NGM primer to the CFA recipes repo at one point? So maybe reject this suggestion in favor or keeping this primer very general?

Loading