Learn R Programming

cuRe (version 1.0.0)

general.haz: Extract general population hazard

Description

Yearly general population hazards matched on age, gender, and calendar year is extracted from a ratetable.

Usage

general.haz(time, age, sex, year, data = NULL,
  ratetable = cuRe::survexp.dk)

Arguments

time

Either a numeric vector of follow-up times (in days) or a character indicating the variable containing the follow-up times in the data.

age

Either a numeric vector of ages (in days) or a character indicating the variable containing the patient ages in the data.

sex

Either a character vector or factor with the sex of each patient or a character indicating the variable containing the patient sex in the data.

year

Either a vector of class Date with the calendar time points or a character indicating the variable containing the calendar times in the data.

data

The data from which to extract variables from. If time, age, sex, or year are not characters, this will not be used.

ratetable

Object of class ratetable to extract background hazards from. Defaults to survexp.dk.

Value

An object of class numeric containing the yearly expected hazards.

Examples

Run this code
# NOT RUN {
##Use data cleaned version of the colon cancer data from the rstpm2 package
data("colonDC")
set.seed(2)
colonDC <- colonDC[sample(1:nrow(colonDC), 1000), ]

##Extract general population hazards
bhaz1 <- general.haz(time = "FU", age = "agedays", sex = "sex", year = "dx",
                     data = colonDC, ratetable = survexp.dk)

bhaz2 <- general.haz(time = colonDC$FU, age = colonDC$agedays, sex = colonDC$sex,
                     year = colonDC$dx, ratetable = survexp.dk)
all(bhaz2 == bhaz1)
# }

Run the code above in your browser using DataLab