Hybrid Model for the Age of Infection
AoI-Hybrid.Rmd
We have developed a hybrid model that we can use to compute the mean and higher order moments for the age of infection (AoI). In a related vignette (AoI), we define the AoI as a random variable and develop functions to compute its moments. Here, we develop a notation for the moments:
Let x=⟨A⟩; x is the first moment of the AoI in a cohort at age a, conditioned on a history of exposure, given by a function h. In longer form: xτ(a;h)=⟨Aτ(a;h)⟩=∫∞0αzτ(α,a;hτ(a))mτ(a;hτ(a)) Here, we show that:
dxda=1−hmx
Similarly, we let x[n]=⟨An⟩ denote the higher order moments of the random variable A. In longer form: xn(a,τ;h)=∫∞0αnzτ(α,a;hτ(a))mτ(a;hτ(a)) We show that higher order moments can be computed recursively:
dx[n]da=nx[n−1]−hmx[n]
In the following, we first demonstrate that the hybrid equations give the same answers as direct computation of the moments.
Hybrid Model
The function solve_dAoI
computes the first three moments
of the AoI by default. Here we plot the nth root of the first three
moments.
par(mar = c(7, 4, 2, 2))
solve_dAoI(5/365, foiP3) -> mt
plot(mt$time, mt$xn1, type = "l", xlab = "Age (in Days)", ylab = expression(list(x, sqrt(x[paste("[2]")]), sqrt(x[paste("[3]")], 3))), ylim = range(mt$xn3^(1/3)))
lines(mt$time, mt$xn2^(1/2), col = "purple")
lines(mt$time, mt$xn3^(1/3), col = "darkgreen")
## Numerical Verification
aa = seq(1, 5*365, by = 5)
moment1 = momentAoI(aa, foiP3)
moment2 = momentAoI(aa, foiP3, n=2)
moment3 = momentAoI(aa, foiP3, n=3)
- By solving a hybrid model with variables that track the moments, using the equations that we derived above:
solve_dAoI(5/365, foiP3, Tmax = 5*365, dt=5) -> mt
par(mfrow = c(2,2), mar = c(7, 4, 2, 2))
# Top Left
plot(mt$time, mt$xn1, type = "l", xlab = "Age (in Days)", ylab = expression(x), lwd=3)
lines(aa, moment1, col = "yellow", lwd=2, lty=2)
# Top Right
plot(mt$time, mt$xn2, type = "l", xlab = "Age (in Days)", ylab = expression(x[paste("[2]")]), lwd=3, col = "purple")
lines(aa, moment2, col = "yellow", lwd=2, lty=2)
plot(mt$time, mt$xn3, type = "l", lwd=3, col = "darkgreen",
xlab = "Age (in Days)", ylab = expression(x[paste("[3]")]))
lines(aa, moment3, col = "yellow", lwd=2, lty=2)
par(mar = c(7, 4, 2, 2))
solve_dAoI(5/365, foiP3) -> mt
plot(mt$time, mt$xn1, type = "l", xlab = "Age (in Days)", ylab = expression(list(x, sqrt(x[paste("[2]")]), sqrt(x[paste("[3]")], 3))), lwd=3, ylim = range(mt$xn3^(1/3)))
lines(mt$time, mt$xn2^(1/2), col = "purple", lwd=3)
lines(mt$time, mt$xn3^(1/3), col = "darkgreen", lwd=3)
lines(aa, moment1, col = "yellow", lwd=2, lty=2)
lines(aa, moment2^(1/2), col = "yellow", lwd=2, lty=2)
lines(aa, moment3^(1/3), col = "yellow", lwd=2, lty=2)
Derivation for dx/da
In Dynamics, we present an equation for zτ(α,a), the density function for infections of age α in a host cohort of age a born on day τ. The dynamics of z(α,a) are described by the following:
∂z∂a+∂z∂α=−rz
with the boundary condition:
zτ(0,a)=hτ(a)
and its solutions are:
zτ(α,a)=hτ(a−α)e−rα
In MoI, we defined the distribution function for the MoI:
Mτ(a)∼fM(ζ;a,τ)=Pois(mτ(a))
and we showed that the mean MoI, mτ(a) is:
mτ(a)=∫a0zτ(α,a)dα
In AoI, we defined a probability density function for the AoI:
Aτ(a)∼fA(α;a,τ)=zτ(α,a)mτ(a)
Here, we derive an equation for dxda=d⟨A⟩da
We start by multiplying Eq. 1 by α and integrating with respect to α:
∫a0α∂z(α,a)∂adα+∫a0α∂z(α,a)∂αdα=−r∫a0αz(α,a)dα,
By its definition,
∫a0αz(α,a)dα=⟨A⟩m
So we can simplify a bit:
∂⟨A⟩m∂adα+∫a0α∂z=−r⟨A⟩m
On the RHS of Eq. 2, the first term can be rewritten:
∂⟨A⟩m∂a=m∂⟨A⟩∂a+⟨A⟩∂m∂a
On the RHS of Eq. 2, the second term can be rewritten by integrating by parts:
∫a0α∂z=αz(a,α)|α=a−αz(a,α)|α=0−∫a0zdα
which simplifies to:
∫a0α∂z=ahd(0)e−ra−m
Substituting, we get:
m∂⟨A⟩∂a+⟨A⟩∂m∂a+ahd(0)e−ra−m=−r⟨A⟩m
We divide through by m and rearrange to get:
∂⟨A⟩∂a=−⟨A⟩m∂m∂a−amhd(0)e−ra+1−r⟨A⟩
We substitute dm/da=h−rm and simplify:
∂⟨A⟩∂a=−⟨A⟩m(h−rm)−amhd(0)e−ra+1−r⟨A⟩
and after rearranging terms and cancelling:
∂⟨A⟩∂a=1−h⟨A⟩m−amhd(0)e−ra
or since we are letting x=⟨A⟩ dxda=1−hmx−amhd(0)e−ra
I can’t remember why that last term goes away
Noting that: lim
Derivation for dx_n/da
To derive a tracking equation for \left<A^n \right>, we start as before but multiply by \alpha^n to get:
\begin{equation} \int_0^a \alpha^n \frac{\partial z}{\partial a} \partial \alpha + \int_0^a \alpha^n \frac{\partial z}{\partial \alpha} \partial \alpha = \int_0^a - r \alpha^n z \partial \alpha \end{equation} which we can rewrite as: \begin{equation} \frac{\partial \left<A^n \right> m}{\partial a} + \int_0^a \alpha^n \partial x = - r \left<A^n\right> m \end{equation}
Integrating the middle term by parts,
\begin{equation} \int_0^a \alpha^n \partial z = \alpha^n z(a,\alpha) \big|_{\alpha = 0}^{a} - n \int_0^a \alpha^{n-1} z d\alpha \end{equation}
so we can rearrange this to get Eq.~\ref{dAnda}. Once again, we are concerned with the limits as m becomes small:
\begin{equation} \lim_{m\rightarrow 0} \frac{A}{m} = \lim_{m\rightarrow 0} \frac{a}{m} = 1 \end{equation}