Skip to contents

socialmixr is an R package to derive social mixing matrices from survey data.

Installation

The package can be installed using

install.packages("socialmixr")

The current development version can be installed using the remotes package

remotes::install_github("epiforecasts/socialmixr")

Usage

Contact matrices are computed through a small pipeline of composable functions: subsetting the survey, assigning age groups, optionally weighing participants, and computing the matrix. A minimal example using the included POLYMOD data:

library(socialmixr)
data(polymod)

polymod[country == "United Kingdom"] |>
  assign_age_groups(age_limits = c(0, 1, 5, 15)) |>
  compute_matrix()

Post-processing functions symmetrise(), split_matrix() and per_capita() can be piped after compute_matrix() to enforce symmetry, decompose the matrix, or convert to per-capita contact rates.

Documentation

For more on how to use the socialmixr package, see the introduction vignette.

Contributors

All contributions to this project are gratefully acknowledged using the allcontributors package following the allcontributors specification. Contributions of any kind are welcome!

Issue Contributors

vikkytom, bahadzie, joshwlambert