View source: R/fun-modify_LT.R
modify_cod_table | R Documentation |
Modify COD table by changing the cause of death associated risks
modify_cod_table(cod, cod_change)
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. |
A long table with the same format as the input data
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.