
Integrate Serial Interval Component Functions for Likelihood Calculation
Source:R/integrate_component.R
integrate_component.Rd
This function performs numerical integration of serial interval component functions used in the Vink method for estimating serial interval distributions. It integrates the probability density functions for different transmission routes over specified intervals as part of the Expectation-Maximization algorithm.
Usage
integrate_component(
d,
mu,
sigma,
comp,
dist = c("normal", "gamma"),
lower = TRUE
)
Arguments
- d
numeric; the index case-to-case (ICC) interval in days for which to calculate the likelihood contribution
- mu
numeric; the mean of the serial interval distribution in days
- sigma
numeric; the standard deviation of the serial interval distribution in days
- comp
integer; the transmission route component number (1 to 7). See Details for component definitions
- dist
character; the assumed underlying distribution of the serial interval. Must be either "normal" or "gamma". Defaults to "normal"
- lower
logical; if
TRUE
(default), performs integration usingflower
andfupper
functions. IfFALSE
, usesf0
function
Value
numeric; the integrated likelihood value for the specified component and data point. Used in the EM algorithm for serial interval estimation
Details
The function supports two integration modes:
lower = TRUE
: Integrates usingflower
andfupper
functions over intervals[d-1, d]
and[d, d+1]
respectively, representing the likelihood contribution when case occurs at day dlower = FALSE
: Integrates usingf0
function over interval[d, d+1]
, representing an alternative likelihood formulation
The components represent different transmission routes in outbreak analysis:
Component 1: Co-Primary (CP) transmission
Components 2+3: Primary-Secondary (PS) transmission
Components 4+5: Primary-Tertiary (PT) transmission
Components 6+7: Primary-Quaternary (PQ) transmission
This function is primarily used internally by si_estim()
as part of the Vink method for estimating serial interval parameters from outbreak data.
References
Vink MA, Bootsma MCJ, Wallinga J (2014). Serial intervals of respiratory infectious diseases: A systematic review and analysis. American Journal of Epidemiology, 180(9), 865-875.
Examples
# Basic example with lower integration (default)
# Component 2 represents primary-secondary transmission
integrate_component(d = 15, mu = 12, sigma = 3, comp = 2, dist = "normal", lower = TRUE)
#> [1] 0.08065146
# Upper integration example
integrate_component(d = 15, mu = 12, sigma = 3, comp = 2, dist = "normal", lower = FALSE)
#> [1] -1.951533
# Using gamma distribution
integrate_component(d = 10, mu = 8, sigma = 2, comp = 1, dist = "gamma", lower = TRUE)
#> [1] 0.0009500035
# Component 1 (co-primary transmission) with normal distribution
integrate_component(d = 5, mu = 10, sigma = 3, comp = 1, dist = "normal", lower = TRUE)
#> [1] 0.09407604
# Compare different components for the same data point
d_val <- 20
mu_val <- 15
sigma_val <- 4
# Calculate for components 1, 2, and 4 (different transmission routes)
sapply(c(1, 2, 4), function(comp) {
integrate_component(d_val, mu_val, sigma_val, comp, "normal", lower = TRUE)
})
#> [1] 0.0002805022 0.0457941110 0.0148641350