Skip to contents

This vignette outlines the design decisions that have been taken during the development of the contactmatrix R package, and provides some of the reasoning, and possible pros and cons of each decision.

This document is primarily intended to be read by those interested in understanding the code within the package and for potential package contributors.

Scope

This package aims to provide a standardised way of dealing with empirical and synthetic social contacts data, such as data from the socialmixr, contactdata, and conmat R packages. The main rationale is to allow downstream analysis and modelling packages to seamlessly switch from one package to the other without having to reformat the input data. This new contact matrix package will provide a shared, basic, contact matrix class. It is expected that some packages will use this class as an single element in a more complex list output (e.g., socialmixr also includes a citation element)

Classes

contactmatrix

    • ✓ used in socialmixr
    • ✓ used in contactdata
    • ✓ used in conmat
    • ✓ used in socialmixr
    • ✓ used in contactdata
    • ✗ transposed in conmat
    • ✓ used in socialmixr
    • ✓ used in conmat plots
    • ✓ used in Epiverse-TRACE plots

Special case of multiple groupings

Although currently rare, we can theoretically consider contact matrices with multiple groupings (e.g. age & gender). To ensure forward-compatibility if this ever becomes more common practice, we allow multiple groupings in the form or multi-dimensional arrays.

contactmatrix_list

A list of contactmatrix from different settings, or just different runs of the socialmixr algorithm to convert survey data to a contact matrix.

Functions and methods

Class infrastructure

    • an assert_<class>(x) function which returns an error or x invisibly
    • a test_<class>(x) function which returns a boolean

Custom methods

Helpers

Dependencies

This package is placed at the low position in the dependency stack, and should therefore depend itself on as few packages as possible.