create_asr() calculate age-standardized rates (ASRs) from object with class of canreg, canregs, fbswicd, or fbswicds. It supports stratification by multiple variables, allows the specification of different standard population structures, and provides flexibility in the inclusion of variance, confidence intervals, and population data.

create_asr(
  x,
  ...,
  event = "fbs",
  std = c("cn2000", "wld85"),
  cancer_type = "big",
  mp = 1e+05,
  decimal = 2,
  show_var = FALSE,
  show_ci = FALSE,
  collapse = TRUE
)

# S3 method for class 'canregs'
create_asr(x, ..., cancer_type = "big", collapse = TRUE)

# S3 method for class 'canreg'
create_asr(x, ..., cancer_type = "big")

# S3 method for class 'fbswicds'
create_asr(
  x,
  ...,
  event = "fbs",
  std = c("cn2000", "wld85"),
  mp = 1e+05,
  decimal = 2,
  show_pop = FALSE,
  show_var = FALSE,
  show_ci = FALSE,
  collapse = TRUE
)

# S3 method for class 'fbswicd'
create_asr(
  x,
  ...,
  event = "fbs",
  std = c("cn2000", "wld85"),
  mp = 1e+05,
  decimal = 2,
  show_pop = FALSE,
  show_var = FALSE,
  show_ci = FALSE
)

Arguments

x

The input data, object with class of 'fbswicd', 'fbswicds', 'canreg', or 'canregs'.

...

One or more variables used for stratification. For example, you can stratify by sex, year, cancer, or just by year. If sex is not passed as a parameter, the output will be the result for the combined gender.

event

A variable used to specify the type of calculation, options are "fbs" or "sws", "fbs" for cancer incidence, and "sws" for cancer mortality.

std

Specify the standard population structure in the 'std_pop' data frame used for calculating standardized rates. When calculating standardized rates for multiple standard populations, specify std = c(segi, china).

cancer_type

A character string specifying the classification method used to categorize ICD-10 codes. This determines how ICD-10 codes are classified. Options include "big" (classify ICD-10 codes into 26 cancer categories), "small" (classify ICD-10 codes into 59 cancer categories, more specific categories), "system" (classify ICD-10 codes into organ system), and "gco" (classify ICD-10 code into cancer categories same as classification published by the Global Cancer Observatory). This parameter is only available when the input data is a vector of ICD-10 codes, or object with class of 'canreg' or 'canregs'.

mp

A constant to multiply rates by (e.g. mp=1000 for rates per 1000).

decimal

This parameter specifies the number of decimal places to round the results. The default is 2, which means rates will be rounded to two decimal places.

show_var

Logical value whether output variance or not.

show_ci

Logical value whether output confidence(lower or upper bound) or not.

collapse

Logical value whether output result as asr or asrs.

show_pop

Logical value whether output population or not.

Value

A data frame or tibble contains the age standard rates and CIs.

See also

ageadjust for age-adjusted rate calculations. truncrate for truncated rate calculations.

Examples

data("canregs")
asr_inci <- create_asr(canregs, event = "fbs", year, sex, cancer)
asr_mort <- create_asr(canregs, event = "sws", year, sex, cancer)

# calculate ASR based on object with class of `canregs`
asr <- create_asr(canregs, event = "sws", year, sex, cancer)

# calculate ASR based on object with class of `canreg`
data <- canregs[[1]]
# calculate ASR using default parameter
asr <- create_asr(data, year, sex, cancer)
head(asr)
#> # A tibble: 6 × 12
#>    year   sex cancer no_cases    cr asr_cn2000 asr_wld85 truncr_cn2000
#>   <int> <dbl> <chr>     <dbl> <dbl>      <dbl>     <dbl>         <dbl>
#> 1  2021     0 101          38  5.53       3.74      3.79          6.37
#> 2  2021     0 102           5  0.73       0.71      0.71          1.19
#> 3  2021     0 103          59  8.58       4.53      4.85          7.56
#> 4  2021     0 104         123 17.9       11.1      11.2          18.1 
#> 5  2021     0 105         236 34.3       20.6      20.2          34.1 
#> 6  2021     0 106         128 18.6       11.5      11.4          21.7 
#> # ℹ 4 more variables: truncr_wld85 <dbl>, cumur <dbl>, prop <dbl>, rank <int>
# calculate ASR using multiple standard population
asr_multi_std <- create_asr(data, year, sex, cancer,
  std = c("cn82", "cn2000", "wld85")
)
head(asr_multi_std)
#> # A tibble: 6 × 14
#>    year   sex cancer no_cases    cr asr_cn82 asr_cn2000 asr_wld85 truncr_cn82
#>   <int> <dbl> <chr>     <dbl> <dbl>    <dbl>      <dbl>     <dbl>       <dbl>
#> 1  2021     0 101          38  5.53     3.07       3.74      3.79        6.89
#> 2  2021     0 102           5  0.73     0.74       0.71      0.71        1.21
#> 3  2021     0 103          59  8.58     3.26       4.53      4.85        8.28
#> 4  2021     0 104         123 17.9      8.33      11.1      11.2        19.5 
#> 5  2021     0 105         236 34.3     14.9       20.6      20.2        36.2 
#> 6  2021     0 106         128 18.6      8.6       11.5      11.4        23.1 
#> # ℹ 5 more variables: truncr_cn2000 <dbl>, truncr_wld85 <dbl>, cumur <dbl>,
#> #   prop <dbl>, rank <int>
# calculate ASR with confidence interval
asr_with_ci <- create_asr(data, year, sex, cancer, show_ci = TRUE)
head(asr_with_ci)
#> # A tibble: 6 × 18
#>    year   sex cancer no_cases    cr cr_lower cr_upper asr_cn2000
#>   <int> <dbl> <chr>     <dbl> <dbl>    <dbl>    <dbl>      <dbl>
#> 1  2021     0 101          38  5.53     3.91     7.59       3.74
#> 2  2021     0 102           5  0.73     0.24     1.7        0.71
#> 3  2021     0 103          59  8.58     6.53    11.1        4.53
#> 4  2021     0 104         123 17.9     14.9     21.4       11.1 
#> 5  2021     0 105         236 34.3     30.1     39.0       20.6 
#> 6  2021     0 106         128 18.6     15.5     22.1       11.5 
#> # ℹ 10 more variables: asr_lower_cn2000 <dbl>, asr_upper_cn2000 <dbl>,
#> #   asr_wld85 <dbl>, asr_lower_wld85 <dbl>, asr_upper_wld85 <dbl>,
#> #   truncr_cn2000 <dbl>, truncr_wld85 <dbl>, cumur <dbl>, prop <dbl>,
#> #   rank <int>
# calculate ASR with population at risk
asr_with_pop <- create_asr(data, year, sex, cancer, show_pop = TRUE)
head((asr_with_pop))
#> # A tibble: 6 × 13
#>    year   sex cancer    pop no_cases    cr asr_cn2000 asr_wld85 truncr_cn2000
#>   <int> <dbl> <chr>   <dbl>    <dbl> <dbl>      <dbl>     <dbl>         <dbl>
#> 1  2021     0 101    687356       38  5.53       3.74      3.79          6.37
#> 2  2021     0 102    687356        5  0.73       0.71      0.71          1.19
#> 3  2021     0 103    687356       59  8.58       4.53      4.85          7.56
#> 4  2021     0 104    687356      123 17.9       11.1      11.2          18.1 
#> 5  2021     0 105    687356      236 34.3       20.6      20.2          34.1 
#> 6  2021     0 106    687356      128 18.6       11.5      11.4          21.7 
#> # ℹ 4 more variables: truncr_wld85 <dbl>, cumur <dbl>, prop <dbl>, rank <int>
# calculate ASR with variance
asr_with_var <- create_asr(data, year, sex, cancer, show_var = TRUE)
head(asr_with_var)
#> # A tibble: 6 × 15
#>    year   sex cancer no_cases    cr   cr_var asr_cn2000 asr_var_cn2000 asr_wld85
#>   <int> <dbl> <chr>     <dbl> <dbl>    <dbl>      <dbl>          <dbl>     <dbl>
#> 1  2021     0 101          38  5.53 8.04e-11       3.74       4.57e-11      3.79
#> 2  2021     0 102           5  0.73 1.06e-11       0.71       1.25e-11      0.71
#> 3  2021     0 103          59  8.58 1.25e-10       4.53       4.01e-11      4.85
#> 4  2021     0 104         123 17.9  2.60e-10      11.1        1.16e-10     11.2 
#> 5  2021     0 105         236 34.3  5.00e-10      20.6        1.99e-10     20.2 
#> 6  2021     0 106         128 18.6  2.71e-10      11.5        1.15e-10     11.4 
#> # ℹ 6 more variables: asr_var_wld85 <dbl>, truncr_cn2000 <dbl>,
#> #   truncr_wld85 <dbl>, cumur <dbl>, prop <dbl>, rank <int>

# calculate ASR based on object with class of `fbswicds`
# convert object with class of `canregs` to object with class of `fbswicds`
fbsws <- count_canreg(canregs)
asrs <- create_asr(fbsws, event = "sws", year, sex, cancer)

# calculate ASR based on object with class of `fbswicd`
# convert object with class of `canreg` to object with class of `fbswicd`
fbsw <- count_canreg(canregs[[1]])
asr <- create_asr(fbsw, event = "sws", year, sex, cancer)