Calculate a normalised risk ration from proportions
Source:R/normalised-proportion.R
normalise_proportion.Rd
This assumes 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 groups.
Arguments
- modelled
Model output from processing the
raw
dataframe with something likeproportion_locfit_model
A dataframe containing the following columns:
time (as.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 (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)
No mandatory groupings.
No default value.
- base
The baseline data must be grouped in the same way as
modelled
.A dataframe containing the following columns:
baseline_proportion (proportion) - Size of population
No mandatory groupings.
No default value.
- ...
not used
Value
a dataframe with incidence rates per unit capita. A dataframe containing the following columns:
time (as.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 (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)
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
baseline_proportion (proportion) - The population baseline risk from which the excess risk ratio is based
No mandatory groupings.
No default value.
Examples
tmp = growthrates::england_covid %>%
growthrates::proportion_locfit_model(window=21) %>%
growthrates::normalise_proportion(growthrates::england_demographics) %>%
dplyr::glimpse()
#> Rows: 26,790
#> Columns: 17
#> 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.5 <dbl> 1.465037e-06, 1.891110e-06, 2.501801e-06, 3.371…
#> $ 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.5 <dbl> 0.24102860, 0.24048966, 0.23901181, 0.23680352,…
#> $ relative.growth.0.975 <dbl> 2.6535715, 2.6428288, 2.6133706, 2.5693525, 2.5…
#> $ population <dbl> 3077000, 3077000, 3077000, 3077000, 3077000, 30…
#> $ 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…
plot_growth_phase(tmp)
#> Coordinate system already present. Adding new coordinate system, which will
#> replace the existing one.