Decompose a contact matrix into mean contacts, normalisation and assortativity
Source:R/postprocess-matrix.R
split_matrix.RdSplits the contact matrix into the mean number of contacts across the whole
population (mean.contacts), a normalisation constant (normalisation),
age-specific contact rates (contacts), and an assortativity matrix
(replacing $matrix). For details, see the "Getting Started" vignette.
Arguments
- x
a list as returned by
compute_matrix(), with elementsmatrixandparticipants- survey_pop
a data frame with columns
lower.age.limitandpopulation(e.g. fromwpp_age())- ...
passed to
pop_age()for interpolation
Value
x with $matrix replaced by the assortativity matrix, plus
additional elements $mean.contacts, $normalisation, and $contacts
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() |>
split_matrix(survey_pop = pop)
#>
#> ── Contact matrix (3 age groups) ──
#>
#> Ages: "[0,5)", "[5,15)", and "[15,Inf)"
#> Participants: 1011
#> Mean contacts: 11.56
#>
#> contact.age.group
#> age.group [0,5) [5,15) [15,Inf)
#> [0,5) 3.7686417 1.316910 0.7592908
#> [5,15) 0.6290397 4.415104 0.5158328
#> [15,Inf) 0.6044752 0.934443 1.0374170