Package {epiDeaths}


Type: Package
Title: Functions for Calculating Mortality Indicators
Version: 1.1.8
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.
License: GPL (≥ 3)
Encoding: UTF-8
RoxygenNote: 7.3.2
NeedsCompilation: no
Packaged: 2026-05-16 03:21:04 UTC; zenit
Author: Edson Zangiacomi Martinez ORCID iD [aut, cre], Jackeline Suzan Gentil Garcia dos Anjos ORCID iD [ctb]
Maintainer: Edson Zangiacomi Martinez <edson@fmrp.usp.br>
Repository: CRAN
Date/Publication: 2026-05-20 09:00:02 UTC

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:

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)

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 = \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:

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))

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 i-th age group by d_i, the YPLL can be estimated by

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

where K^* is the number of age groups between 0 and K, a_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:

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)

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

r_{sx} = \left(\dfrac{pop_{1sx}}{pop_{2sx}}\right)^{1/\Delta t} - 1

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

Value

The function returns a list containing two components:

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)

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 = \sum\limits_{i=1}^{K^*} \dfrac{a_i d_i}{p_i} N_i

where K^* is the number of age groups between 0 and K, a_i is the difference between K and the midpoint of age in each age group, assuming a uniform distribution of deaths in each group, d_i is the number of deaths in the i-th age group (d), p_i is the population size for each age group within the study population (pop), and N_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 = \dfrac{ASYPLL}{\sum_{i=1}^{K^*} N_i} \times C

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

Value

Returns a list with five components:

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)