aggregate_contact_matrix
aggregate_contact_matrix.Rd
Aggregate and Rescale a Square Contact Matrix
Arguments
- mat
A square numeric matrix of contact rates (e.g., 101 x 101 for ages 0–100).
- age_breaks
Numeric vector of lower age boundaries for groups (e.g.,
c(0, 5, 10, ..., Inf)
).- population
A data frame with columns
time
,age
(integer, 1-based), andvalue
(population count).- symmetric
Logical; if
TRUE
, enforces reciprocity between age groups (default:TRUE
).
Details
Aggregates a square contact matrix to custom age groups using population-weighted means, then rescales the result to preserve the total sum of the original matrix.
The function first computes the mean population per single-year age across time,
assigns each age to a group defined by age_breaks
, and aggregates the contact matrix
using population-weighted averages. It then rescales the aggregated matrix so that
the total sum is equal to that of the original matrix. Optionally, it enforces symmetry
(reciprocity) using population group weights.