Symmetrise a contact matrix based on population sizes
Source:R/make_cmat_symmetric.R
make_cmat_symmetric.RdThe symmetry is achieved to ensure that n(i) * c(i, j) == n(j) * c(j, i)
where n(i) is the population size of age group i and c(i, j) is the
contact rate from age group i to age group j.
Details
This function was adapted from that described in socialmixr::symmetrise()
to work with a simple matrix and population vector. The process is
implemented as described in the original function, replacing the ij-th
entries with (c_ij * N_i + c_ji * N_j) / 2 and divided by the population
size of the respective age group to ensure that the resulting matrix is
symmetric with respect to the population sizes.
The resulting matrix will satisfy the condition that
n(i) * c(i, j) == n(j) * c(j, i) for all age groups i and j, ensuring
that the total number of contacts from age group i to age group j is
equal to the total number of contacts from age group j to age group i.
The operation will change the row and column sums of the contact matrix.