Learn R Programming

socialmixr (version 0.7.0)

normalise_weights_to_counts: Normalise a weighted contact array to mean contacts per participant

Description

Divides the rank-2K array of weighted contact counts produced by weighted_matrix_array() by the participant-side weight totals (cross-tabulated over the same grouping columns), giving the mean number of contacts per participant. Cells with no participants become NA.

Usage

normalise_weights_to_counts(
  sampled_participants,
  weighted_matrix,
  groupings = default_age_groupings()
)

Value

the array with the same dim and dimnames as weighted_matrix

Arguments

sampled_participants

the sampled participants data.table (must have sampled.weight plus the participant columns referenced by groupings)

weighted_matrix

a rank-2K array of weighted contact counts

groupings

a list of grouping triples (see resolve_groupings()); defaults to single-age, matching pre-existing single-grouping output