compute_matrix: Compute contact matrix from prepared survey data

View source: R/compute-matrix.R

compute_matrixR Documentation

Compute contact matrix from prepared survey data

Description

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().

Usage

compute_matrix(survey, counts = FALSE, weight_threshold = NULL)

Arguments

survey

a survey() object with age groups assigned (via assign_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)

Value

a list with elements matrix and participants

Examples

data(polymod)
polymod |>
  assign_age_groups(age_limits = c(0, 5, 15)) |>
  compute_matrix()


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