Skip to contents

Add fractions of the population in each age group that attend school/work (average FTE) to compute the probability that both participant and contact attend school/work. Requires columns age_to and age_from. Note that it will operate on any column starting with age. Adds columns: school_probability, work_probability, school_year_probability, and school_weighted_pop_fraction. The columns school_probability and work_probability represent the probability a person of the other age goes to the same work/school. school_year_probability represents the probability that a person of the other age would be in the same school year. school_weighted_pop_fraction represents the weighted combination of contact population age distribution & school year probability, so that if the contact is in the same school year, the weight is 1, and otherwise it is the population age fraction. This can be used as an offset, so that population age distribution can be used outside the classroom, but does not affect classroom contacts (which due to cohorting and regularised class sizes are unlikely to depend on the population age distribution).

Usage

add_school_work_participation(contact_data)

Arguments

contact_data

contact data containing columns: age_to, age_from, and pop_age_to (from add_population_age_to())

Value

dataset with 9 extra columns: school_fraction_age_from, work_fraction_age_from, school_fraction_age_to, work_fraction_age_to, school_probability, work_probability, school_year_probability, and school_weighted_pop_fraction.

Note

this uses fake data that will get replaced with abs data input soon

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,
)

example_df %>%
  add_population_age_to() %>%
  add_school_work_participation()
#> # A tibble: 36 × 12
#>    age_from age_to pop_age_to intergen…¹ schoo…² work_…³ schoo…⁴ work_…⁵ schoo…⁶
#>       <int>  <int>      <dbl>      <int>   <dbl>   <dbl>   <dbl>   <dbl>   <dbl>
#>  1       10     10      0.161          0       1    0.05       1    0.05       1
#>  2       10     11      0.163          1       1    0.05       1    0.05       1
#>  3       10     12      0.165          2       1    0.05       1    0.2        1
#>  4       10     13      0.168          3       1    0.05       1    0.2        1
#>  5       10     14      0.170          4       1    0.05       1    0.2        1
#>  6       10     15      0.173          5       1    0.05       1    0.2        1
#>  7       11     10      0.161          1       1    0.05       1    0.05       1
#>  8       11     11      0.163          0       1    0.05       1    0.05       1
#>  9       11     12      0.165          1       1    0.05       1    0.2        1
#> 10       11     13      0.168          2       1    0.05       1    0.2        1
#> # … with 26 more rows, 3 more variables: work_probability <dbl>,
#> #   school_year_probability <dbl>, school_weighted_pop_fraction <dbl>, and
#> #   abbreviated variable names ¹​intergenerational, ²​school_fraction_age_from,
#> #   ³​work_fraction_age_from, ⁴​school_fraction_age_to, ⁵​work_fraction_age_to,
#> #   ⁶​school_probability