modify_cod_table: Modify COD table by changing the cause of death associated...

View source: R/fun-modify_LT.R

modify_cod_tableR Documentation

Modify COD table by changing the cause of death associated risks

Description

Modify COD table by changing the cause of death associated risks

Usage

modify_cod_table(cod, cod_change)

Arguments

cod

Causes of death matrix containing death counts corresponding to the population and time period of the life table;

cod_change

Numerical scalar, vector or matrix. The changes to be applied to the causes of death rate, m[c,x], in order to reduce or increase the mortality estimates given by the life table. Accepted input: any value greater than -100. See examples.

Value

A long table with the same format as the input data

Examples

D <- data_gbd2021_cod # cod data

# Select COD data
cod <- D[D$region == "Romania" & D$sex == "both" & D$period == 2021, ]
cod_change = -50

# Example 1:
# Modify by 50% all COD values. This is trivial and not need really.
modify_cod_table(cod, cod_change = -50)


# Example 2:
# Change the first cod by 1%, second one with 2% and so on until 17%
modify_cod_table(cod, cod_change = 1:17)

# Example 3:
# Apply a specific change by cause and age
# Say, we want to decrease the cod's risk only between age 45 and 75
# with values between 24% and 40%.

# we have to build a matrix with 25 rows and 18 columns (AGEs x CODs)
# to indicate the change for each combination
M <- matrix(24:40, nrow = 25, ncol = 18, byrow = TRUE)
dimnames(M) <- list(unique(cod$x), unique(cod$cause_name))
M[!(rownames(M) %in% 45:75), ] <- 0
M

modify_cod_table(cod, cod_change = -M)

mpascariu/MortalityCauses documentation built on April 17, 2025, 8:31 p.m.