Computes a contact matrix from a contact_survey that has been processed
by assign_age_groups() and optionally weigh(). This is the final step
in the pipeline workflow.
For post-processing, pipe the result into symmetrise(),
split_matrix(), or per_capita().
Arguments
- survey
a
survey()object with age groups assigned (viaassign_age_groups())- counts
whether to return counts instead of means
- weight_threshold
numeric; if provided, weights above this threshold are capped to the threshold value and then re-normalised (default NULL)
Examples
data(polymod)
polymod |>
assign_age_groups(age_limits = c(0, 5, 15)) |>
compute_matrix()
#>
#> ── Contact matrix (3 age groups) ──
#>
#> Ages: "[0,5)", "[5,15)", and "[15,Inf)"
#> Participants: 7198
#>
#> contact.age.group
#> age.group [0,5) [5,15) [15,Inf)
#> [0,5) 2.2370031 1.556575 6.434251
#> [5,15) 0.5252009 8.948137 7.100804
#> [15,Inf) 0.3478261 1.019710 11.705507