Skip to contents

This assumes that for example, case distribution proportions are stratified by a population grouping, e.g. geography or age, and we have estimates of the size of that population during that time period. Normalising by population proportion allows us to compare the relative risk of the outcome in groups, compared to the expected population risk if the outcome is evenly distributed across the population. There may be other proportions other than population fractions that may be useful to compare. At the moment this does not handle any uncertainty.

Usage

infer_risk_ratio(
  modelled = i_proportion_model,
  base = i_baseline_proportion_data,
  ...
)

Arguments

modelled

Model output from something like proportion_locfit_model()

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`

  • proportion.fit (double) - an estimate of the proportion on a logit scale

  • proportion.se.fit (positive_double) - the standard error of proportion estimate on a logit scale

  • proportion.0.025 (proportion) - lower confidence limit of proportion (true scale)

  • proportion.0.5 (proportion) - median estimate of proportion (true scale)

  • proportion.0.975 (proportion) - upper confidence limit of proportion (true scale)

Any grouping allowed.

base

The baseline data must be grouped in the same way as modelled. It may be a time series but does not have to be.

A dataframe containing the following columns:

  • baseline_proportion (proportion) - Baseline proportion for comparison

Any grouping allowed.

...

not used

Value

a dataframe with relative risk / risk ratio columns. 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

  • risk_ratio.0.025 (positive_double) - lower confidence limit of the excess risk ratio for a population group

  • risk_ratio.0.5 (positive_double) - median estimate of the excess risk ratio for a population group

  • risk_ratio.0.975 (positive_double) - upper confidence limit of the excess risk ratio for a population group

Any grouping allowed.

Examples




tmp = ggoutbreak::england_covid %>%
  ggoutbreak::proportion_locfit_model(window=21) %>%
  ggoutbreak::infer_risk_ratio(ggoutbreak::england_demographics) %>%
  dplyr::glimpse()
#> Rows: 26,790
#> Columns: 24
#> Groups: class [19]
#> $ class                  <fct> 00_04, 00_04, 00_04, 00_04, 00_04, 00_04, 00_04…
#> $ time                   <time_prd> 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, …
#> $ proportion.fit         <dbl> -13.433629, -13.178345, -12.898497, -12.600007,…
#> $ proportion.se.fit      <dbl> 51.598289, 49.954079, 48.024633, 45.878749, 43.…
#> $ proportion.0.025       <dbl> 1.759164e-50, 5.698079e-49, 3.308357e-47, 2.991…
#> $ proportion.0.05        <dbl> 2.025665e-43, 3.908217e-42, 1.235425e-40, 5.680…
#> $ proportion.0.25        <dbl> 1.125403e-21, 4.403625e-21, 2.140592e-20, 1.226…
#> $ proportion.0.5         <dbl> 1.465037e-06, 1.891110e-06, 2.501801e-06, 3.371…
#> $ proportion.0.75        <dbl> 1.0000000, 1.0000000, 1.0000000, 1.0000000, 1.0…
#> $ proportion.0.95        <dbl> 1.0000000, 1.0000000, 1.0000000, 1.0000000, 1.0…
#> $ proportion.0.975       <dbl> 1.0000000, 1.0000000, 1.0000000, 1.0000000, 1.0…
#> $ relative.growth.fit    <dbl> 0.24102860, 0.24048966, 0.23901181, 0.23680352,…
#> $ relative.growth.se.fit <dbl> 1.2309119, 1.2257057, 1.2114298, 1.1900979, 1.1…
#> $ relative.growth.0.025  <dbl> -2.1715143, -2.1618494, -2.1353470, -2.0957455,…
#> $ relative.growth.0.05   <dbl> -1.7836413, -1.7756169, -1.7536129, -1.7207333,…
#> $ relative.growth.0.25   <dbl> -0.5892088, -0.5862363, -0.5780852, -0.5659053,…
#> $ relative.growth.0.5    <dbl> 0.24102860, 0.24048966, 0.23901181, 0.23680352,…
#> $ relative.growth.0.75   <dbl> 1.0712660, 1.0672156, 1.0561088, 1.0395124, 1.0…
#> $ relative.growth.0.95   <dbl> 2.2656985, 2.2565962, 2.2316365, 2.1943404, 2.1…
#> $ relative.growth.0.975  <dbl> 2.6535715, 2.6428288, 2.6133706, 2.5693525, 2.5…
#> $ baseline_proportion    <dbl> 0.05447011, 0.05447011, 0.05447011, 0.05447011,…
#> $ risk_ratio.0.025       <dbl> 3.229595e-49, 1.046093e-47, 6.073711e-46, 5.491…
#> $ risk_ratio.0.5         <dbl> 2.689616e-05, 3.471831e-05, 4.592981e-05, 6.190…
#> $ risk_ratio.0.975       <dbl> 18.35869, 18.35869, 18.35869, 18.35869, 18.3586…

if(interactive()) {
  plot_growth_phase(tmp)
}