Package 'epiDeaths'

Title: Functions for Calculating Mortality Indicators
Description: Provides functions for calculating mortality indicators. These include geometric interpolation between two periods and projections for future years, as described in the textbook by Laurenti, Mello Jorge, Lebrão and Gotlieb (2005, ISBN:9788512408309), the standardised mortality ratio (Bruce, Pope and Stanistreet, 2018, ISBN:9781118665411), the age-adjusted mortality rate (direct standardisation), years of potential life lost (Gardner and Sanborn, 1990, <doi:10.1097/00001648-199007000-00012>; Ma, Ward, Siegel and Jemal, 2015, <doi:10.1001/jama.2015.12319>), and age-standardised years of potential life lost (Silva Filho et al., 2024 <doi:10.1590/1413-81232024293.04702023EN>). Confidence intervals for the standardised mortality ratio are obtained according to Vandenbroucke (1982) <doi:10.1093/oxfordjournals.aje.a113306> and Ulm (1990) <doi:10.1093/oxfordjournals.aje.a115507>. The function also includes a function that produces a graph similar to an age pyramid.
Authors: Edson Zangiacomi Martinez [aut, cre] (ORCID: <https://orcid.org/0000-0002-0949-3222>), Jackeline Suzan Gentil Garcia dos Anjos [ctb] (ORCID: <https://orcid.org/0000-0003-0426-8787>)
Maintainer: Edson Zangiacomi Martinez <[email protected]>
License: GPL (>= 3)
Version: 1.1.8
Built: 2026-05-20 13:46:09 UTC
Source: https://github.com/cran/epiDeaths

Help Index


AAMR: Age-adjusted mortality rate

Description

Calculates the age-adjusted mortality rate (direct standardisation).

Usage

AAMR(d, pop, Nref, ages = c(), fac = 10000)

Arguments

d

a vector containing the number of deaths in each age group in the study population.

pop

a vector containing the population size for each age group within the study population.

Nref

a vector containing the population size for each age group within the reference population.

ages

a vector containing the lower limit of each age group.

fac

a factor used to represent the mortality rate as "deaths per fac population". The default is 1e4.

Value

Returns a list with three components:

  • crude: The crude mortality rate.

  • adj: The age-adjusted mortality rate.

  • tabm: A matrix containing "d", "pop", "Nref" and the expected number of deaths at each age group.

References

Bruce, N., Pope, D., Stanistreet, D. (2018). Quantitative Methods for Health Research: A Practical Interactive Guide to Epidemiology and Statistics. Second Edition. John Wiley & Sons Ltd.

Examples

## Example 1
d    <- c(1,14,102,259,381,420,328,297)
pop  <- c(670858,1530547,1591913,1551481,1355325,1068705,604175,332148)
Nref <- c(7058427,15541422,16281290,15382114,12733791,9626735,5432779,2828223)
AAMR(d,pop,Nref,ages=c(15,20,30,40,50,60,70,80,100))

## Example 2
# Bruce et al. (2018), Exercise 3.3.1, p. 111.
d    <- c(15,31,78)
pop  <- c(4100,3000,2900)
Nref <- c(5000,3500,1500)
AAMR(d,pop,Nref,ages=c(65,75,85,100),fac=1000)

bar2plot: Distribution of age groups

Description

A graph showing the distribution of age groups within a population, divided by sex

Usage

bar2plot(
  x,
  y,
  main = "",
  a = 1.5,
  corb = c("#1a80bb", "#bf4124"),
  border = "black",
  legm = c(),
  cexlegm = 1,
  cexleg = 1,
  xleg = "Age groups",
  labgroups = c("male", "female"),
  big.mark = ","
)

Arguments

x

a vector of values for the left side of the graph.

y

a vector of values for the right side of the graph.

main

main title.

a

a numerical value that controls the size of the horizontal space between the bars. The default is 1.5.

corb

a vector of colors to be used to fill the bars. The default is c("#bf4124","#1a80bb").

border

the color of the border around the bars. The default is "black".

legm

a label vector for the bars, which will be displayed in the centre of the chart. If this is not specified, 'Age 1', 'Age 2', and so on will be displayed.

cexlegm

a numerical value that controls the size of the labels for the bars. The default is 1.

cexleg

a numerical value that controls the size of the of labels at the bottom of the plot. The default is 1.

xleg

a label showed at the bottom of the plot. The default is "Age groups".

labgroups

a label vector for the left and right sides of the graph. The default is c("male","female").

big.mark

the symbol used to add thousands separators to large numbers, making them easier to read. The default is ",".

Details

This function produces a graph similar to an age pyramid. It shows the distribution of various age groups within a population, divided by sex. Males are displayed on the left and females on the right, with the youngest age groups at the base and the oldest at the top.

Value

The function returns a plot (silently).

Examples

## Example 1
x <- sample(100000:999999,6)
y <- sample(100000:999999,6)
bar2plot(x,y,main="Title",cexleg=0.8,border=NA)

## Example 2
# Brazilian population. Demographic census, 2022.
# Data from the Brazilian Institute of Geography and Statistics (IBGE)
x <- c(6461689, 7011282, 6992746, 7317515, 7767306, 7627458, 7537285,
       7827333, 7781059, 6549109, 6014391, 5419505, 4605834, 3588052,
       2615350, 1657786, 1009852, 493649, 194341, 50319, 10570)
y <- c(6243171, 6738158, 6682215, 7058427, 7699157, 7842265, 7935832,
       8345458, 8291111, 7091003, 6584190, 6149601, 5338555, 4288180,
       3243186, 2189593, 1465178, 835554, 385388, 114859, 27244)
ages <- c("0 to 4", "5 to 9", "10 to 14", "15 to 19", "20 to 24",
          "25 to 29", "30 to 34", "35 to 39", "40 to 44", "45 to 49",
          "50 to 54", "55 to 59", "60 to 64", "65 to 69", "70 to 74",
          "75 to 79", "80 to 84", "85 to 89", "90 to 94", "95 to 99",
          "100+")
bar2plot(x,y,main="Brazil 2022",cexleg=0.8,border=NA,legm=ages,cexlegm=0.8)

interpol: Geometric interpolation between two years

Description

Calculates intermediate values between a starting value and an ending value by finding an average annual growth rate.

Usage

interpol(pop1, pop2, from = 2010, to = 2022)

Arguments

pop1

a vector of the initial values.

pop2

a vector of the ending values.

from

initial year or data point.

to

ending year or data point.

Details

This function uses geometric interpolation to calculate intermediate values between a starting value and an ending value. The growth rate by sex (s) and age group (x) is given by

rsx=(pop1sxpop2sx)1/Δt1r_{sx} = \left(\dfrac{pop_{1sx}}{pop_{2sx}}\right)^{1/\Delta t} - 1

where pop1sxpop_{1sx} and pop2sxpop_{2sx} are the populations for the initial and final data points, respectively, and Δt\Delta t is the time elapsed between the two dates.

Value

The function returns a list containing two components:

  • rsx: The growth rates.

  • interpdata: A matrix of the intermediate values.

References

Laurenti, R., Mello Jorge, M.H.P., Lebrão, M.L., Gotlieb, S.L.D. (2005). Estatísticas de Saúde. 2nd edition. São Paulo: EPU. ISBN: 9788512408309.

Examples

# Example 1
# Laurenti et al. (1985), page 34
# Brazilian population in 1970:  93,215,300
# Brazilian population in 1980: 119,098,992
interpol(93215300, 119098992, 1970, 1980)

# Example 2
pop1 <- c(2126148L, 775746L, 884602L, 957100L, 911673L, 812483L, 747361L, 688740L,
          614103L, 501228L, 386337L, 274949L, 216546L)
pop2 <- c(1787296L, 648467L, 752059L, 783322L, 808350L, 881275L, 892896L, 771218L,
          713233L, 649157L, 581323L, 472760L, 356725L)
out  <- interpol(pop1,pop2,from=2010,to=2022)
out$rsx        # the annual growth rate
out$interpdata # a matrix of the intermediate values

project: Geometric population projection

Description

Geometric population projection is a forecasting method assuming a constant percentage growth rate over time.

Usage

project(pop1, pop2, from = 2010, to = 2022, x = 2025)

Arguments

pop1

a vector of the initial values.

pop2

a vector of the ending values.

from

initial year or data point.

to

ending year or data point.

x

the year for which the extrapolation is to be made.

Details

This function estimate values for a given year (x) based on growth rates calculated by geometric interpolation between from and to.

Value

This function returns a vector containing the extrapolated values.

References

Laurenti, R., Mello Jorge, M.H.P., Lebrão, M.L., Gotlieb, S.L.D. (2005). Estatísticas de Saúde. 2nd edition. São Paulo: EPU. ISBN: 9788512408309.

Examples

## Example 1
project(100, 200, from=2010, to=2020, x=2025)

## Example 2
pop1 <- c(2126148L, 775746L, 884602L, 957100L, 911673L, 812483L, 747361L, 688740L,
          614103L, 501228L, 386337L, 274949L, 216546L)
pop2 <- c(1787296L, 648467L, 752059L, 783322L, 808350L, 881275L, 892896L, 771218L,
          713233L, 649157L, 581323L, 472760L, 356725L)
project(pop1, pop2, from=2010, to=2022, x=2025)

SMR: Standardized mortality ratio

Description

Calculates the Standardized Mortality Ratio (SMR), a measure comparing the observed number of deaths in a study population to the expected deaths based on a standard population, adjusted for age and sex.

Usage

SMR(d, pop, dref, Nref, ages = c())

Arguments

d

a vector containing the number of deaths in each age group in the study population.

pop

a vector containing the population size for each age group within the study population.

dref

a vector containing the number of deaths in each age group in the reference population.

Nref

a vector containing the population size for each age group within the reference population.

ages

a vector containing the lower limit of each age group.

Details

An SMR is calculated by the indirect method of standardisation. It compares the actual deaths in a study population to the deaths that would be expected if that population had the same age/sex-specific mortality rates as a standard population. SMR is calculated as

SMR=observed number of deathsexpected number of deathsSMR = \dfrac{observed\ number\ of\ deaths}{expected\ number\ of\ deaths}

It is commonly used in epidemiology for age-standardized mortality comparisons. An SMR of 1.0 means that the number of observed deaths is equal to the number of expected deaths. An SMR higher than 1.0 indicates higher-than-expected mortality, while an SMR lower than 1.0 indicates lower-than-expected mortality.

Value

Returns a list with six components:

  • obs: The observed number of deaths.

  • exp: The expected number of death.

  • smr: The standardized mortality ratio (SMR).

  • ci: An approximate 95% confidence interval (CI) for the SMR by using the method proposed by Vandenbroucke (1982).

  • isr: The indirectly standardised mortality rate per 10,000 inhabitants, given by 10,000 x SMR x crude death rate for the standard population (see Bruce et al., 2018, p. 110).

  • tabm: A matrix containing "d", "pop", "dref", "Nref" and the expected number of deaths at each age group.

References

Bruce, N., Pope, D., Stanistreet, D. (2018). Quantitative Methods for Health Research: A Practical Interactive Guide to Epidemiology and Statistics. Second Edition. John Wiley & Sons Ltd. ISBN: 9781118665411.

Ulm, K. (1990). Simple method to calculate the confidence interval of a standardized mortality ratio (SMR). American Journal of Epidemiology, 131:373–37, doi:10.1093/oxfordjournals.aje.a115507

Vandenbroucke, J.P. (1982). A shortcut method for calculating the 95 percent confidence interval of the standardized mortality ratio. (Letter). American Journal of Epidemiology, 115:303-4, doi:10.1093/oxfordjournals.aje.a113306

Examples

## Example
d    <- c(1,14,102,259,381,420,328,297)
pop  <- c(670858,1530547,1591913,1551481,1355325,1068705,604175,332148)
Nref <- c(7058427,15541422,16281290,15382114,12733791,9626735,5432779,2828223)
dref <- c(2,136,1185,2826,4188,4311,3384,3071)
SMR(d,pop,dref,Nref,ages=c(15,20,30,40,50,60,70,80,100))

stdYPLL: Age‐standardized years of potential life lost

Description

Calculates the age‐standardized YPLL, a measure of the amount of life lost due to premature mortality.

Usage

stdYPLL(d, pop, Nref, ages = ages, K = 75, fac = 10000)

Arguments

d

a vector containing the number of deaths in each age group in the study population.

pop

a vector containing the population size for each age group within the study population.

Nref

a vector containing the population size for each age group within the reference population.

ages

a vector containing the lower limit of each age group.

K

the standard life expectancy age. The default is 75 years.

fac

a factor used to represent the mortality rate as "deaths per fac population". The default is 1e4.

Details

Age-Standardized Years of Potential Life Lost (ASYPLL) involves adjusting the YPLL rate of a specific population to a standard population structure to allow for fair comparisons across different regions or time periods. This measure is given by

ASYPLL=i=1KaidipiNiASYPLL = \sum\limits_{i=1}^{K^*} \dfrac{a_i d_i}{p_i} N_i

where KK^* is the number of age groups between 0 and K, aia_i is the difference between K and the midpoint of age in each age group, assuming a uniform distribution of deaths in each group, did_i is the number of deaths in the ii-th age group (d), pip_i is the population size for each age group within the study population (pop), and NiN_i the population size for each age group within the reference population (Nref) (Silva Filho et al., 2024).

The age‐standardized YPLL rate is given by

ASYPLL rate=ASYPLLi=1KNi×CASYPLL\ rate = \dfrac{ASYPLL}{\sum_{i=1}^{K^*} N_i} \times C

These measure is interpreted in years per CC people, where CC is specified by the argument fac.

Value

Returns a list with five components:

  • out: A matrix containing in its columns the number of deaths in each age group (did_i), the correspondent midpoint of age, the difference between the midpoint of age and K (aia_i), the product aidia_i d_i, the population size for each age group within the reference population, the age‑specific YPLL rates (YPLL per person), and the age‑specific YPLL, respectively.

  • ypll: The crude estimate of YPLL.

  • ypllrate: The YPLL rate in years per fac people.

  • stdypll: The age‐standardized YPLL.

  • stdypllrate: The age‐standardized YPLL rate in years per fac people.

References

Silva Filho, A.M.D., Araújo, E.M.D., Souza, I.M.D., Luiz, O.D.C., Máximo, G., Queiroz, F.D.A., Cavalcante, L., Nisida, V. (2024). Years of potential life lost due to COVID-19 according to race/color and gender in Brazil between 2020 and 2021. Ciência & Saúde Coletiva, 29, e04702023. doi: 10.1590/1413-81232024293.04702023EN

Examples

# Example 1
d    <- c(0,0,1,12,60,100,137,200,225,236,237,258,226)
pop  <- c(1787296,648467,752059,783322,808350,881275,892896,
          771218,713233,649157,581323,472760,356725)
Nref <- c(3906682,1396816,1584091,1655473,1730527,1873165,1902856,
          1639164,1534930,1433780,1294948,1054437,795497)
ages <- c(0,15,20,25,30,35,40,45,50,55,60,65,70)
stdYPLL(d,pop,Nref,ages)

# Example 2
d <- c(10,50,20)
pop  <- c(50000,40000,10000)
Nref <- c(20000,20000,10000)
ages <- c(0,35,65)
stdYPLL(d,pop,Nref,ages)

YPLL: Years of potential life lost

Description

Calculates the YPLL, a measure of the amount of life lost due to premature mortality.

Usage

YPLL(d, ages = ages, K = 75)

Arguments

d

a vector containing the number of deaths in each age group.

ages

a vector containing the lower limit of each age group.

K

the standard life expectancy age. The default is 75 years.

Details

The concept of years of potential life lost (YPLL) involves estimating the average time a person would have lived had he or she not died prematurely (Gardner and Sanborn, 1990). Denoting the number of deaths in the ii-th age group by did_i, the YPLL can be estimated by

YPLL=i=1KaidiYPLL = \sum_{i=1}^{K^*} a_i d_i

where KK^* is the number of age groups between 0 and K, aia_i is the difference between K and the midpoint of age in each age group, assuming a uniform distribution of deaths in each group, and K is the standard age of death. The midpoint of an age group is estimated as (lowest age + highest age + 1)/2.

Different authors use different values for K. According to Bruce et al. (2018), historically, WHO has used life expectancy from Japan, this being the highest in the world. Other authors uses 75 years as the reference age because it approximates US life expectancy (Ma et al., 2015).

Value

Returns a list with two components:

  • out: A matrix containing the number of deaths in each age group (did_i), the correspondent midpoint of age, the difference between the midpoint of age and K (aia_i), and the product aidia_i d_i.

  • estimate: The years of potential life lost.

References

Bruce, N., Pope, D., Stanistreet, D. (2018). Quantitative Methods for Health Research: A Practical Interactive Guide to Epidemiology and Statistics. Second Edition. John Wiley & Sons Ltd.

Gardner, J.W., Sanborn, J.S. (1990). Years of potential life lost (YPLL) - what does it measure? Epidemiology, 1(4):322-9. doi: 10.1097/00001648-199007000-00012.

Ma, J., Ward, E.M., Siegel, R.L., Jemal, A. (2015). Temporal trends in mortality in the United States, 1969-2013. Jama, 314(16), 1731-1739. doi: 10.1001/jama.2015.12319.

Examples

# Example
d    <- c(1,12,60,100,137,200,225,236,237,258,226)
ages <- seq(20,70,5)
YPLL(d,ages,75)