aggregate_predicted_contacts: Aggregate predicted contacts to specified age breaks

View source: R/aggregate_predicted_contacts.R

aggregate_predicted_contactsR Documentation

Aggregate predicted contacts to specified age breaks

Description

Aggregates contacts rate from, say, a 1 year level into provided age breaks, weighting the contact rate by the specified age population. For example, if you specify breaks as c(0, 5, 10, 15, Inf), it will return age groups as 0-5, 5-10, 10-15, and 15+ (Inf). Used internally within predict_contacts(), although can be used by users.

Usage

aggregate_predicted_contacts(
  predicted_contacts_1y,
  population,
  age_breaks = c(seq(0, 75, by = 5), Inf)
)

Arguments

predicted_contacts_1y

contacts in 1 year breaks (could technically by in other year breaks). Data must contain columns, age_from, age_to, contacts, and se_contacts, which is the same output as predict_contacts_1y() - see examples below.

population

a conmat_population object, which has the age and population columns specified, or a dataframe with columns lower.age.limit, and population. See examples below.

age_breaks

vector of ages. Default: c(seq(0, 75, by = 5), Inf)

Value

data frame with columns, age_group_from, age_group_to, and contacts, which is the aggregated model.

Examples

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_contacts_1 <- predict_contacts_1y(
  model = polymod_setting_models$home,
  population = fairfield,
  age_min = 0,
  age_max = 15
)

fairfield_contacts_1

aggregated_fairfield <- aggregate_predicted_contacts(
  predicted_contacts_1y = fairfield_contacts_1,
  population = fairfield,
  age_breaks = c(0, 5, 10, 15, Inf)
)

aggregated_fairfield

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