Age of the Youngest Infection (AoY)
AoY.Rmd
We want to derive a random variable describing the age of the youngest infection (AoY). The derivations are presented below:
We compute the distribution function first:
FY(a)∼1−e−mτ(a)FA(α,a,τ)1−e−mτ(a)=1−e−mτ(a)FA(α,a,τ)pτ(a)
We differentiate to get a formula for the density function:
Yτ(a)∼fY(α;a,τ)=fA(α,a,τ)e−mτ(a)FA(α,a,τ)mτ(a)pτ(a)
The mean AoY is:
⟨Yτ(a)⟩=∫a0αfY(α,a,τ)dα
And the higher order moments for the AoY are:
⟨Yτ(a)n⟩=∫n0αnfy(α,a,τ)dα
Moments
aa = seq(5, 5*365, by = 5)
moment1y = momentAoY(aa, foiP3)
moment2y = momentAoY(aa, foiP3, n=2)
moment3y = momentAoY(aa, foiP3, n=3)
The first three moments of the AoY plotted over time. In the top plot, we’ve also plotted the nth root of the nth moment.
par(mfrow = c(4,1), mar = c(0.5, 4, 0.5, 2))
plot(aa, moment1y, type = "l", xlab = "", ylab = expression(E(Y)), lwd=2, xaxt="n", ylim = range((moment3y)^(1/3)) )
lines(aa, sqrt(moment2y), col = "darkgreen")
lines(aa, (moment3y)^(1/3), col = "purple")
plot(aa, moment2y, type = "l", xlab = "", ylab = expression(E(Y^2)), lwd=2, xaxt="n", col = "darkgreen")
plot(aa, moment3y, type = "l", xlab = "", ylab = expression(E(Y^2)), lwd=2, col = "purple")
mtext("Age (in Days)", 1, 3)
Derivation
First, we note that the CDF for the minimum of n random values of AoI in some cohort is:
1−(1−FA(α,a,τ))n Using this, we can compute the CDF for the full distribution of AoY across the population:
FY(α,a,τ)=1pτ(a)∑ζ>0dpois(ζ,mτ(a))(1−(1−FA(α,a,τ))ζ)
or rewriting slightly:
FY(α,a,τ)pτ(a)=∑ζ>0mτ(a)ζζ!e−mτ(a)(1−(1−FA(α,a,τ))ζ)
pulling out e−mτ(a) and recombining terms, we get:
FY(α,a,τ)pτ(a)=pτ(a)−e−mτ(a)∑ζ>0[mτ(a)(1−FA(α,a,τ))]ζζ! if the sum were from ζ=0…∞, the expression on the inside would be simple, but the sum is for M>0, so we add the term for M=0 into the sum, subtract it outside:
FY(α,a,τ)pτ(a)=pτ(a)−e−mτ(a)(−1+∑ζ>=0[mτ(a)(1−FA(α,a))]ζζ!)
but e−mτ(a)=1−pτ(a) and the infinite sum is simply an exponential, so:
FY(α,a,τ)pτ(a)=pτ(a)+1−pτ(a)−e−mτ(a)emτ(a)(1−FA(α,a,τ)) so
FY(α,a,τ)pτ(a)=1−e−mτ(a)Fa(α,a)
and
FY(α,a,τ)=1−e−mτ(a)FA(α,a,τ)pτ(a).
The PDF for the AoY is found by taking the derivative of FY:
Y∼fY(α,a,τ)=dFY(α,a,τ)dα=fA(α,a)e−mτ(a)FA(α,a,τ)mτ(a)pτ(a)