csu_asr: csu_asr

View source: R/csu_asr.R

csu_asrR Documentation

csu_asr

Description

csu_asr calculate Age-Standardized Rate (ASR) and Truncated Age-Standardized Rate (TASR) across different population (Registry, year, sex...)

Usage

csu_asr(df_data,
		var_age = "age",
		var_cases = "cases",
		var_py ="py",
		group_by=NULL,
		var_age_group=NULL,
		missing_age = NULL,
		db_rate = 100000,
		first_age = 1,
		last_age = 18,
		pop_base = "SEGI",
		crude_rate = FALSE,
		var_st_err = NULL,
		correction_info = FALSE,
		var_asr = "asr",
		age_dropped = FALSE)

Arguments

df_data

Data (need to be R data.frame format, see example to import csv file).

var_age

Age variable. Several format are accepted

1 "0-4" 0
2 "5-9" 5
3 "10-14" 10
... ... ...
17 "80-84" 80
18 "85+" 85

Missing age value must be precise in the option missing_age.
Last age group will always be considere without size (ie: 80+,85+, etc..).

var_cases

Number of event (cases, deaths, ...) variable.

var_py

Population year variable.

group_by

A vector of variables to compare different ASR (sex, country, cancer ...).
Any variable included in the next option var_age_group must be also include here.

var_age_group

Variables over which the number of population age-group might change.
For example the last age group (70+, 75+, 80+ or 85+) can vary across registries, or year, but not across sex.

missing_age

Age value representing the missing age cases.
If not precise, missing age value will not affect the calculation.

db_rate

The denominator population. Default is 100000.

first_age

First age group included (for Truncated ASR), must be between 1 and 17. 1 represents 0-4, 2 represents 5-9, ... 5 represents 20-24 etc.

last_age

Last age group included (for Truncated ASR), must be between 2 and 18. 2 represents 5-9, ... 5 represents 20-24, ... 18 represents 85+ etc.
To calculate ASR for 15-69 years, use: first_age(4), last_age(14).

pop_base

Select the standard population:

"SEGI" SEGI world standard population (1960).
"EURO" EURO is the European standard population (1976).
"EURO2" EURO2 is the European standard population (2013).
"WHO" WHO is the WHO standard population (2001).
crude_rate

Logical value. if TRUE calculate the crude rate instead of the ASR.
Variables var_age_group, missing_age, pop_base, var_st_err, correction_info are not used.
Default name of the new variable is "crude_rate".

var_st_err

Calculate the Standard error and name of the new variable.

correction_info

Logical value. if TRUE compute the variable "correction" : percentage of missing age cases.

var_asr

Name of the new variable for the ASR.

age_dropped

Only for truncated ASR.
Logical value: if TRUE, Assume the age group not used are already dropped from the data.
First_age and last_age option must still be filled.

Details

This function take automatically account the number of age group (last age group can be 70+,75+,80+,85+):
If the population data stops before 85+ (75+ for instance), the population data must be 0 when the population data is unknown so, the program can detect automatically the last age group (70+,75+,80+ or 85+) for population.

Value

Give the list of population with less than 18 age group (last age group: 70+, 75+, 80+).
Return a data.frame.

Author(s)

Mathieu Laversanne

References

https://publications.iarc.fr/_publications/media/download/3753/609d0d7711047dd76d7f3dbaa25d7f041fcd013e.pdf

See Also

csu_group_cases csu_merge_cases_pop csu_cumrisk csu_eapc csu_ageSpecific csu_ageSpecific_top csu_bar_top csu_time_trend csu_trendCohortPeriod

Examples

data(csu_registry_data_1)
data(csu_registry_data_2)

# you can import your data from csv file using read.csv:
# mydata <-  read.csv("mydata.csv", sep=",")

# Age standardized rate (ASR) with no missing age cases.
result <- csu_asr(csu_registry_data_1, 
                  "age", "cases", "py",
                  group_by = c("registry", "registry_label" ),
                  var_age_group = c("registry_label"))
				  
# you can export your result as csv file using write.csv:
# write.csv(result, file="result.csv")
				  
# ASR,  with the percentage of correction due to missing age cases. 
result <- csu_asr(csu_registry_data_1, 
                  "age", "cases", "py",
                  group_by = c("registry", "registry_label" ),
                  var_age_group = c("registry_label"),
				  missing_age = 19,				  
				  correction_info = TRUE)	
				  
# ASR and standard error with missing age.
result <- csu_asr(csu_registry_data_2, 
                  "age", "cases", "py",
                  group_by = c("registry", "registry_label", "sex", "year", "ethnic" ),
                  var_age_group = c("registry_label"), 
                  var_st_err = "st_err",
				  missing_age = 99)
				  
# Truncated ASR, 25-69 years.
result <- csu_asr(csu_registry_data_2, 
                  "age", "cases", "py",
                  group_by = c("registry", "registry_label", "sex", "year", "ethnic" ),
                  var_age_group = c("registry_label"), 
                  var_st_err = "st_err",
				  first_age = 6, 
				  last_age = 14,
				  missing_age = 99)	

# Truncated ASR, 0-15 with denominator population = 1000000. 
result <- csu_asr(csu_registry_data_2, 
                  "age", "cases", "py",
                  group_by = c("registry", "registry_label", "sex", "year", "ethnic" ),
                  var_age_group = c("registry_label"), 
                  var_st_err = "st_err",
				  first_age = 1, 
				  last_age = 3, 
				  missing_age = 99,	
				  db_rate = 1000000)		
				  
# ASR with EURO population as reference (instead of SEGI)
result <- csu_asr(csu_registry_data_1, 
                  "age", "cases", "py",
                  group_by = c("registry", "registry_label" ),
                  var_age_group = c("registry_label"),
				  missing_age = 19,
                  pop_base = "EURO")
				    		  

Rcan documentation built on Oct. 7, 2024, 1:18 a.m.