symmetrise: Symmetrise a contact matrix

View source: R/postprocess-matrix.R

symmetriseR Documentation

Symmetrise a contact matrix

Description

Makes a contact matrix symmetric so that c_{ij} N_i = c_{ji} N_j, where c_{ij} is the (i, j) entry and N_i is the population of age group i. This is done by replacing each pair with half their sum, weighted by population size.

Usage

symmetrise(x, survey_pop, symmetric_norm_threshold = 2, ...)

Arguments

x

a list as returned by compute_matrix(), with elements matrix and participants

survey_pop

a data frame with columns lower.age.limit and population (e.g. from wpp_age())

symmetric_norm_threshold

threshold for the normalisation factor before issuing a warning (default 2)

...

passed to pop_age() for interpolation

Value

x with ⁠$matrix⁠ replaced by the symmetrised version

Examples

data(polymod)
pop <- wpp_age("United Kingdom", 2005)
polymod |>
  (\(s) s[country == "United Kingdom"])() |>
  assign_age_groups(age_limits = c(0, 5, 15)) |>
  compute_matrix() |>
  symmetrise(survey_pop = pop)


socialmixr documentation built on April 29, 2026, 9:07 a.m.