socialmixr is an R
package to derive social mixing matrices from survey data.
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")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.
For more on how to use the socialmixr package, see the introduction vignette.
All contributions to this project are gratefully acknowledged using the
allcontributors package
following the allcontributors
specification. Contributions of any kind are welcome!
sbfnk, Bisaloo, lwillem, njtierney, alxsrobert, Degoot-AM, pearsonca, jarvisc1, jamesmbaazam, LloydChapman, mariabnd, ukhsa-tt
bastistician, BlackEdder, Pinzo1, florpi, cchauve, thutran, dlaydon, deusthindwa, krivit, linyang17, cliu822, TimTaylor, NaomiWaterlow, aakhmetz, adamkucharski, chitrams, IsaacStopard, avallecam, maishaoshao, FrancescoBonacina, lucy-gf