Skip to contents

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_data <- abs_age_lga("Fairfield (C)")

fairfield_abs_data
#> # A tibble: 18 × 4 (conmat_population)
#>  - age: lower.age.limit
#>  - population: population
#>    lga           lower.age.limit  year population
#>    <chr>                   <dbl> <dbl>      <dbl>
#>  1 Fairfield (C)               0  2020      12261
#>  2 Fairfield (C)               5  2020      13093
#>  3 Fairfield (C)              10  2020      13602
#>  4 Fairfield (C)              15  2020      14323
#>  5 Fairfield (C)              20  2020      15932
#>  6 Fairfield (C)              25  2020      16190
#>  7 Fairfield (C)              30  2020      14134
#>  8 Fairfield (C)              35  2020      13034
#>  9 Fairfield (C)              40  2020      12217
#> 10 Fairfield (C)              45  2020      13449
#> 11 Fairfield (C)              50  2020      13419
#> 12 Fairfield (C)              55  2020      13652
#> 13 Fairfield (C)              60  2020      12907
#> 14 Fairfield (C)              65  2020      10541
#> 15 Fairfield (C)              70  2020       8227
#> 16 Fairfield (C)              75  2020       5598
#> 17 Fairfield (C)              80  2020       4006
#> 18 Fairfield (C)              85  2020       4240

# 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_abs_data,
  age_min = 0,
  age_max = 15
)

fairfield_contacts_1
#> # A tibble: 256 × 4
#>    age_from age_to  contacts se_contacts
#>       <int>  <int> <dbl[1d]>   <dbl[1d]>
#>  1        0      0     0.454      0.0359
#>  2        0      1     0.472      0.0314
#>  3        0      2     0.472      0.0268
#>  4        0      3     0.457      0.0226
#>  5        0      4     0.430      0.0193
#>  6        0      5     0.393      0.0167
#>  7        0      6     0.355      0.0151
#>  8        0      7     0.317      0.0141
#>  9        0      8     0.281      0.0133
#> 10        0      9     0.251      0.0125
#> # … with 246 more rows

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