| Title: | Directly Standardise Rates by Age |
|---|---|
| Description: | Provides functions for age standardisation of epidemiological measures such as incidence and prevalence rates. It allows users to apply standard population structures to observed age-specific estimates in order to obtain comparable summary measures across populations or time periods. Functions support calculation of standardised rates, outcome counts, and corresponding confidence intervals. The tools are designed to facilitate reproducible and transparent adjustment for differences in age distributions in epidemiological and public health research. |
| Authors: | Elin Rowlands [aut, cre] (ORCID: <https://orcid.org/0009-0005-5166-0417>), Marta Alcalde-Herraiz [aut] (ORCID: <https://orcid.org/0009-0002-4405-1814>), Nuria Mercade-Besora [aut] (ORCID: <https://orcid.org/0009-0006-7948-3747>), Edward Burn [aut] (ORCID: <https://orcid.org/0000-0002-9286-1128>), Danielle Newby [aut] (ORCID: <https://orcid.org/0000-0002-3001-1478>) |
| Maintainer: | Elin Rowlands <[email protected]> |
| License: | Apache License (>= 2) |
| Version: | 0.2.0 |
| Built: | 2026-06-01 08:55:08 UTC |
| Source: | https://github.com/oxford-pharmacoepi/epistandard |
Computes crude and directly standardised rates. Rates can be stratified by variables of interest.
directlyStandardiseRates( data, event, denominator, age = "age_group", pop = "pop", strata = NULL, addMissingGroups = TRUE, refdata = standardPopulation("Europe") )directlyStandardiseRates( data, event, denominator, age = "age_group", pop = "pop", strata = NULL, addMissingGroups = TRUE, refdata = standardPopulation("Europe") )
data |
A data frame with the event counts to be standardised. |
event |
Name of the column in data that corresponds to the event counts. |
denominator |
Name of the column in data that corresponds to the denominator population (in person-time, e.g person-days, person-years etc). |
age |
Name of the column in data and refdata that corresponds to age groups. |
pop |
Name of the column in refdata that corresponds to the standard population in each age group. |
strata |
Name of the columns in data for which rates are calculated by. |
addMissingGroups |
If TRUE, any age groups present in refdata but not in data will be added and set to 0. If false, these age groups will be removed from refdata. |
refdata |
A data frame representing the standard population. It must contain two columns: age, with the different age groups (notice that this column name must be the same as in data, defined by the input age); and pop, with the number of individuals in each corresponding age group. |
Data frame with crude and standardised rates.
# An example of calculating directly standardised rates # Data example is from Table 1 (p.132) of Fundamentals of Epidemiology by Schoenbach, 2000. # The following table shows the number of deaths, for 5 different age groups, # in the states of Miami and Alaska: data <- data.frame( state = rep(c('Miami',"Alaska"), c(5,5)), age_groups = rep(c('00-14','15-24','25-44','45-64','65+'),2), deaths = c(136, 57, 208, 1016, 3605, 59, 18, 37, 90, 81), general_population = c(114350,80259,133440,142670,92168,37164,20036,32693,14947,2077)) # We aim to standardise the number of deaths per each state. To do that, we will use the following # US standard population: standardised_population <- data.frame( age_groups = c('00-14','15-24','25-44','45-64','65+'), pop = c(23961000,15420000,21353000,19601000,10685000)) # Now we will use the function dsr to calculate the direct standardised rates # (per 1000 individuals) using a 95% CI calculated by the gamma method: my_results <- directlyStandardiseRates(data = data, event = "deaths", denominator = "general_population", age = "age_groups", pop = "pop", strata = "state", refdata = standardised_population) # View results my_results# An example of calculating directly standardised rates # Data example is from Table 1 (p.132) of Fundamentals of Epidemiology by Schoenbach, 2000. # The following table shows the number of deaths, for 5 different age groups, # in the states of Miami and Alaska: data <- data.frame( state = rep(c('Miami',"Alaska"), c(5,5)), age_groups = rep(c('00-14','15-24','25-44','45-64','65+'),2), deaths = c(136, 57, 208, 1016, 3605, 59, 18, 37, 90, 81), general_population = c(114350,80259,133440,142670,92168,37164,20036,32693,14947,2077)) # We aim to standardise the number of deaths per each state. To do that, we will use the following # US standard population: standardised_population <- data.frame( age_groups = c('00-14','15-24','25-44','45-64','65+'), pop = c(23961000,15420000,21353000,19601000,10685000)) # Now we will use the function dsr to calculate the direct standardised rates # (per 1000 individuals) using a 95% CI calculated by the gamma method: my_results <- directlyStandardiseRates(data = data, event = "deaths", denominator = "general_population", age = "age_groups", pop = "pop", strata = "state", refdata = standardised_population) # View results my_results
Create new merged age groups
mergeAgeGroups( refdata, newGroups, event = NULL, age = "age_group", pop = "pop", ageRange = c(0, 150), strata = NULL )mergeAgeGroups( refdata, newGroups, event = NULL, age = "age_group", pop = "pop", ageRange = c(0, 150), strata = NULL )
refdata |
Standard population dataset you want to use. |
newGroups |
Create a list of new age groups you want to create. |
event |
Column in refdata with outcome counts. |
age |
Column in refdata with age values. |
pop |
Column in refdata with population counts, preferably in person-time. |
ageRange |
Specify the age range of the population of interest. |
strata |
Column or columns to stratify by. |
Data frame with age groups and population counts.
standardPopulation("Europe")|> dplyr::glimpse() merged_data <- mergeAgeGroups(standardPopulation("Europe"), c("0-19", "20-64", "65-150")) merged_data |> dplyr::glimpse()standardPopulation("Europe")|> dplyr::glimpse() merged_data <- mergeAgeGroups(standardPopulation("Europe"), c("0-19", "20-64", "65-150")) merged_data |> dplyr::glimpse()
Standard population
standardPopulation(region = "Europe")standardPopulation(region = "Europe")
region |
Region of standard population. Can be either 'Europe' or 'World'. |
Data frame with age groups and population counts for chosen region.
standard_data <- standardPopulation(region = "Europe")standard_data <- standardPopulation(region = "Europe")