predict_contacts: Predict contact rate between two age populations, given some...

View source: R/predict_contacts.R

predict_contactsR Documentation

Predict contact rate between two age populations, given some model.

Description

Predicts the expected contact rate over specified age breaks, given some model of contact rate and population age structure. This function is used internally in predict_setting_contacts(), which performs this prediction across all settings (home, work, school, other), and optionally performs an adjustment for per capita household size. You can use predict_contacts() by itself, just be aware you will need to separately apply a per capita household size adjustment if required. See details below on adjust_household_contact_matrix for more information.

Usage

predict_contacts(model, population, age_breaks = c(seq(0, 75, by = 5), Inf))

Arguments

model

A single fitted model of contact rate (e.g., fit_single_contact_model())

population

a dataframe of age population information, with columns indicating some lower age limit, and population, (e.g., get_polymod_population())

age_breaks

the ages to predict to. By default, the age breaks are 0-75 in 5 year groups.

Details

The population data is used to determine age range to predict contact rates, and removes ages with zero population, so we do not make predictions for ages with zero populations. Contact rates are predicted yearly between the age groups, using predict_contacts_1y(), then aggregates these predicted contacts using aggregate_predicted_contacts(), which aggregates the predictions back to the same resolution as the data, appropriately weighting the contact rate by the population.

Regarding the adjust_household_contact_matrix function, we use Per-capita household size instead of mean household size. Per-capita household size is different to mean household size, as the household size averaged over people in the population, not over households, so larger households get upweighted. It is calculated by taking a distribution of the number of households of each size in a population, multiplying the size by the household by the household count to get the number of people with that size of household, and computing the population-weighted average of household sizes. We use per-capita household size as it is a more accurate reflection of the average number of household members a person in the population can have contact with.

Value

A dataframe with three columns: age_group_from, age_group_to, and contacts. The age groups are factors, broken up into 5 year bins ⁠[0,5)⁠, ⁠[5,10)⁠. The contact column is the predicted number of contacts from the specified age group to the other one.

Examples

# If we have a model of contact rate at home, and age population structure
# for an LGA, say, Fairfield, in NSW:

polymod_setting_models$home

fairfield <- abs_age_lga("Fairfield (C)")

fairfield

# We can predict the contact rate for Fairfield from the existing contact
# data, say, between the age groups of 0-15 in 5 year bins for school:

fairfield_school_contacts <- predict_contacts(
  model = polymod_setting_models$school,
  population = fairfield,
  age_breaks = c(0, 5, 10, 15, Inf)
)

fairfield_school_contacts


njtierney/conmat documentation built on April 17, 2025, 10:27 p.m.