Skip to contents

This function augments any timeseries with a population denominator. The population data may be static estimates, or a set of estimates at time points. The population data may be grouped in which case the grouping might be geographical area or age group or gender for example. The two inputs must have compatible grouping (i.e. all the groups in the population data must be present in the timeseries).

Usage

infer_population(df = i_timeseries, pop = i_population_data)

Arguments

df

A time series, or a grouped collection of time series.

A dataframe containing the following columns:

  • time (ggoutbreak::time_period + group_unique) - A (usually complete) set of singular observations per unit time as a `time_period`

Any grouping allowed.

pop

The population data must be grouped in the same way as df. It might also have a time column as a time_period if the population is not static

A dataframe containing the following columns:

  • population (positive_integer) - Size of population

Any grouping allowed.

Value

the df timeseries with additional population column

Examples

ggoutbreak::england_covid %>%
  ggoutbreak::infer_population(ggoutbreak::england_demographics) %>%
  dplyr::glimpse()
#> Rows: 26,790
#> Columns: 6
#> Groups: class [19]
#> $ date       <date> 2023-12-09, 2023-12-09, 2023-12-09, 2023-12-09, 2023-12-09…
#> $ class      <fct> 00_04, 05_09, 10_14, 15_19, 20_24, 25_29, 30_34, 35_39, 40_…
#> $ count      <dbl> 24, 8, 8, 4, 21, 20, 29, 36, 41, 59, 53, 54, 56, 54, 67, 72…
#> $ denom      <dbl> 771, 771, 771, 771, 771, 771, 771, 771, 771, 771, 771, 771,…
#> $ time       <time_prd> 1409, 1409, 1409, 1409, 1409, 1409, 1409, 1409, 1409, …
#> $ population <int> 3077000, 3348600, 3413100, 3218900, 3414400, 3715400, 39526…