getHazardFromTable {flexrsurv}R Documentation

computes expected hazards with respect to a reference life table

Description

returns the cumulative hazard and the hazard rate of subjects in a reference life table

Usage

getHazardFromTable(Y, startdate, startage, matchdata = NULL, 
        ratetable = survival::survexp.us, 
		age = 1, year = 2, rmap, agemin = 16, scale = 365.25, 
		ratename = "rateend", 
		cumrateendname = "cumrateend", 
		cumrateentername = "cumrateenter", 
		origin = "01/01/1970", format = "%d/%m/%Y",
		left.open = FALSE, verbose=FALSE)

Arguments

Y

An object with interval data. It can be an object of class Surv with arguments time, time2 and event or a two-column matrix with starting time in the first column and ending time in the second column.

startdate

a numeric vector such that as.Date(startadate) is interpreted as the date of the start (when Y[,]==0).

startage

a numeric vector of age in days the start (when Y[,]==0).

matchdata

an optional data.frame in which to interpret the additional variables to be mapped to the ratetable variables.

ratetable

an object of class ratetable, ie a table of event rates.

age, year

character values of the names of the age and period variables in the rate table.

rmap

an optional list that maps data set names to the ratetable names. See survexp an example bellow.

agemin

numeric value of the age at which the cumulative hazard starts.

scale

numeric value to scale agemin.

ratename, cumrateendname, cumrateentername

names of the returned variables

origin, format

arguments passed as.Date

left.open

logical, passed to findInterval

verbose

logical, if true the progression of the computation is output.

Details

The cumulative rates are computed using survexp.

Value

A data.frame with 3 columns with the rate at the ending time, the cumulative rate from agemin up to the starting time and upt to the ending time.

See Also

getPseudoHazardFromTable for the cumulative hazard in each period of a reference life table. getBrassHazardFromTable for the cumulative hazard in a corrected reference life table. survexp

Examples



if (requireNamespace("relsurv", quietly = TRUE) & requireNamespace("date", quietly = TRUE)) {

	library(date)
	# data from package relsurv
	data(rdata, package="relsurv")
	
	# rate table from package relsurv
	data(slopop, package="relsurv")
	
	tmpsurv <- Surv(rep(0, length(rdata$time)), rdata$time, rdata$cens)
	
	HH <- getHazardFromTable(tmpsurv, startdate=rdata$year,
	               startage=rdata$age*365.24 , matchdata=rdata, ratetable=slopop,
	               age="age", year="year",
	               rmap=list(sex=sex),
	               agemin=18, scale=365.24,
	               ratename = "poprate", 
	               cumrateendname ="cumrateend", 
	               cumrateentername ="cumrateenter"
	               ) 
	summary(HH)
}
						

[Package flexrsurv version 2.0.18 Index]