Learn R Programming

Social mixing matrices for infectious disease modelling in R

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")

Documentation

For information 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!

Code

sbfnk, Bisaloo, lwillem, njtierney, alxsrobert, Degoot-AM, pearsonca, jarvisc1, jamesmbaazam, LloydChapman, mariabnd, ukhsa-tt

Issue Authors

bastistician, BlackEdder, Pinzo1, florpi, cchauve, thutran, dlaydon, deusthindwa, krivit, linyang17, cliu822, TimTaylor, NaomiWaterlow, aakhmetz, adamkucharski, chitrams, IsaacStopard, avallecam, maishaoshao, FrancescoBonacina

Issue Contributors

vikkytom, bahadzie, joshwlambert

Copy Link

Version

Install

install.packages('socialmixr')

Monthly Downloads

1,611

Version

0.5.0

License

MIT + file LICENSE

Issues

Pull Requests

Stars

Forks

Maintainer

Sebastian Funk

Last Published

January 19th, 2026

Functions in socialmixr (0.5.0)

normalise_country_names

Normalise country names
load_survey

Load a survey from local files
matrix_plot

Draws an image plot of a contact matrix with a legend strip and the numeric values in the cells.
impute_ages

Impute ages from ranges (generic helper)
reduce_agegroups

Reduce the number of age groups given a broader set of limits
survey

Contact survey
impute_contact_ages

Impute contact ages
pop_age

Change age groups in population data
polymod

Social contact data from 8 European countries
wpp_age

Get age-specific population data according to the World Population Prospects 2017 edition
get_citation

Citation for a survey
get_survey

Get a survey, either from its Zenodo repository, a set of files, or a survey variable
wpp_countries

List all countries and regions for which socialmixr has population data
download_survey

Download a survey from its Zenodo repository
find_unique_key

Find the minimal unique key for a data.table
check

Check contact survey data
assign_age_groups

Assign age groups in survey data
as_contact_survey

Check contact survey data
list_surveys

List all surveys available for download
limits_to_agegroups

Convert lower age limits to age groups.
is_doi

Checks if a character string is a DOI
clean

Clean contact survey data
contact_matrix

Generate a contact matrix from diary survey data
impute_participant_ages

Impute participant ages
.get_survey

Internal function to get survey data
add_age

Add age column from exact age (generic helper)
deprecate_arg

Handle deprecated argument
new_contact_survey

Contact survey
survey_country_population

Get survey country population data
survey_countries

List all countries contained in a survey