Generation interval density function (dgi), distribution function (pgi), quantile function (qgi), and sampling (rgi). Results are conditional on supplied latent and infectious period distributions. It is assumed
that the latent period and infectious waiting time are independent,
that infectiousness is constant over the infectious period, and
that the latent and infectious periods are positive and integer-valued (in arbitrary but common units of time).
x, q: a numeric vector listing generation intervals.
p: a numeric vector listing probabilities.
n: a non-negative integer indicating a sample size. If length(n) > 1, then length(n) is taken to be the sample size.
latent, infectious: numeric vectors such that latent[i] and infectious[i]
are the probabilities that the latent and infectious periods, respectively, are i units of time. It is sufficient to supply probability weights, as internally both vectors are divided by their sums.
Returns
A numeric vector with length equal to the that of the first argument or length n in the case of rgi.
References
Svensson, Å. (2007). A note on generation times in epidemic models. Mathematical Biosciences, 208(1), 300-311. tools:::Rd_expr_doi("10.1016/j.mbs.2006.10.010")
Examples
latent <- c(0.026,0.104,0.182,0.246,0.318,0.104,0.013,0.004,0.003)m <- length(latent)infectious <- c(0.138,0.462,0.256,0.078,0.041,0.007,0.004,0.004,0.006,0.004)n <- length(infectious)## Histogram of samplesy <- rgi(1e06, latent, infectious)hist(y, breaks = seq(0, m + n +1), freq =FALSE, las =1, ylab ="relative frequency", main ="")## Density and distribution functionsx <- seq(0, m + n +1, by =0.02)fx <- dgi(x, latent, infectious)Fx <- pgi(x, latent, infectious)plot(x, fx, type ="l", las =1,# consistent with histogram xlab ="generation interval", ylab ="density function")plot(x, Fx, type ="l", las =1, xlab ="generation interval", ylab ="distribution function")## Quantile functionp <- seq(0,1, by =0.001)qp <- qgi(p, latent, infectious)plot(p, qp, type ="l", las =1, xlab ="probability", ylab ="quantile function")