add_population_age_to: Add the population distribution for contact ages.

View source: R/add_population_age_to.R

add_population_age_toR Documentation

Add the population distribution for contact ages.

Description

Adds the population distribution of contact ages. Requires a column called "age_to", representing the contact age - the age of the person who had contact. It creates a column, pop_age_to. The population argument defaults to get_polymod_population(), which is a conmat_population object, which has age and population specified. But this can also be a data frame with columns, lower.age.limit, and population. If population is 'polymod' then use the participant-weighted average of POLYMOD country/year distributions. It adds the population via interpolation, using get_age_population_function() to create a function that generates population from ages.

Usage

add_population_age_to(contact_data, population = get_polymod_population())

Arguments

contact_data

contact data containing columns age_to and age_from

population

Defaults to get_polymod_population(), a conmat_population object, which specifies the age and population columns. But it can optionally be any data frame with columns, lower.age.limit, and population.

Value

data frame of contact_data with the number of intergenerational mixing contacts added.

Examples

age_min <- 10
age_max <- 15
all_ages <- age_min:age_max
library(tidyr)
example_df <- expand_grid(
  age_from = all_ages,
  age_to = all_ages,
)
add_population_age_to(example_df)

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