
Calculate a risk ratio from incidence (experimental)
Source:R/normalise-proportion.R
infer_rate_ratio.Rd
This enables incidence rates are able to be compared to a baseline figure for
incidence. The baseline could come for example from a population average or
average incidence over time. The output is an incidence rate ratio. The
incidence_baseline
column is a rate of events per unit time. The time unit
is expected to be the same as that of the date in modelled
and this is not
checked.
Arguments
- modelled
Model output from something like
poisson_locfit_model()
. It really makes sense if this is a grouped 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`
incidence.fit (double) - an estimate of the incidence rate on a log scale
incidence.se.fit (positive_double) - the standard error of the incidence rate estimate on a log scale
incidence.0.025 (positive_double) - lower confidence limit of the incidence rate (true scale)
incidence.0.5 (positive_double) - median estimate of the incidence rate (true scale)
incidence.0.975 (positive_double) - upper confidence limit of the incidence rate (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. See the example and note this may change in the future.A dataframe containing the following columns:
baseline_incidence (positive_double) - Baseline raw incidence rate as count data
Any grouping allowed.
- ...
not used
Value
a dataframe with incidence rate ratios for each of the classes in modelled. 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
rate_ratio.0.025 (positive_double) - lower confidence limit of the rate ratio for a population group
rate_ratio.0.5 (positive_double) - median estimate of the rate ratio for a population group
rate_ratio.0.975 (positive_double) - upper confidence limit of the rate ratio for a population group
Any grouping allowed.
Examples
baseline = ggoutbreak::england_covid %>%
ggoutbreak::time_aggregate() %>%
ggoutbreak::poisson_locfit_model(window=21) %>%
dplyr::mutate(baseline_incidence = incidence.0.5)
tmp = ggoutbreak::england_covid %>%
ggoutbreak::poisson_locfit_model(window=21) %>%
ggoutbreak::infer_rate_ratio(baseline) %>%
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, 00…
#> $ time <time_prd> 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, …
#> $ incidence.fit <dbl> -17.891227, -17.395804, -16.873590, -16.331042, -15…
#> $ incidence.se.fit <dbl> 1.9111699, 1.9238465, 1.9194060, 1.9000358, 1.86810…
#> $ incidence.0.025 <dbl> 4.010032e-10, 6.419738e-10, 1.091671e-09, 1.950766e…
#> $ incidence.0.05 <dbl> 7.323064e-10, 1.177056e-09, 1.998775e-09, 3.549985e…
#> $ incidence.0.25 <dbl> 4.678483e-09, 7.612924e-09, 1.287203e-08, 2.243606e…
#> $ incidence.0.5 <dbl> 1.698004e-08, 2.786752e-08, 4.697785e-08, 8.081996e…
#> $ incidence.0.75 <dbl> 6.162718e-08, 1.020106e-07, 1.714507e-07, 2.911325e…
#> $ incidence.0.95 <dbl> 3.937173e-07, 6.597809e-07, 1.104136e-06, 1.839970e…
#> $ incidence.0.975 <dbl> 7.190010e-07, 1.209705e-06, 2.021596e-06, 3.348359e…
#> $ growth.fit <dbl> 0.4798757, 0.4792888, 0.4776793, 0.4752744, 0.47230…
#> $ growth.se.fit <dbl> 0.05395200, 0.05584978, 0.05729669, 0.05835042, 0.0…
#> $ growth.0.025 <dbl> 0.3741317, 0.3698252, 0.3653799, 0.3609097, 0.35651…
#> $ growth.0.05 <dbl> 0.3911325, 0.3874241, 0.3834346, 0.3792965, 0.37512…
#> $ growth.0.25 <dbl> 0.4434856, 0.4416187, 0.4390333, 0.4359176, 0.43245…
#> $ growth.0.5 <dbl> 0.4798757, 0.4792888, 0.4776793, 0.4752744, 0.47230…
#> $ growth.0.75 <dbl> 0.5162658, 0.5169589, 0.5163253, 0.5146311, 0.51214…
#> $ growth.0.95 <dbl> 0.5686188, 0.5711535, 0.5719240, 0.5712523, 0.56947…
#> $ growth.0.975 <dbl> 0.5856197, 0.5887523, 0.5899788, 0.5896391, 0.58809…
#> $ baseline_incidence <dbl> 0.6431227, 0.6978471, 0.7449065, 0.7855348, 0.82186…
#> $ rate_ratio.0.025 <dbl> 6.235252e-10, 9.199348e-10, 1.465514e-09, 2.483361e…
#> $ rate_ratio.0.5 <dbl> 2.640249e-08, 3.993357e-08, 6.306544e-08, 1.028853e…
#> $ rate_ratio.0.975 <dbl> 1.117984e-06, 1.733481e-06, 2.713893e-06, 4.262522e…