Specify Variables to Match in Rate Table

DESCRIPTION:

Takes a set of arguments specifying the variables to match against in the rate table. This function does no matching or estimation, but assigns attributes to be used by pyears and survexp to aid in their calculations.

USAGE:

ratetable(age, sex, year)

REQUIRED ARGUMENTS:

...
must provide names which match the "dimid" attribute of the rate table being used by pyears or survexp. The units of time for the response variable if present in the formula to pyears or survexp must match the units of time (e.g., age) in the rate table.

VALUE:

a matrix of class "ratetable" with columns corresponding to the arguments to ratetable. For survexp.us the columns are named age, sex, and year . The matrix has attributes necessary for pyears and survexp to complete their computations.

DETAILS:

The purpose of this function is to match the data frame's variables to the proper dimensions of the rate table. Argument order is unimportant but the argument names are. For the survexp.us rate table, the necessary argument names age, sex, and year are contained in the "dimid" attribute. This function is intended to be called in a formula expression and not by itself.

SEE ALSO:

, ,

EXAMPLES:

# Create new data frame with the largest stop value for each patient 
hearta <- by(heart, IND=heart$id, FUN=function(x)x[x$stop==max(x$stop),]) 
hearta <- do.call("rbind", hearta) 
# Estimate of conditional survival  
survexp(stop ~ ratetable(sex="male", year=year*365.25,  
          age=(age+48)*365.25), conditional=T, data=hearta) 
# Estimate of conditional survival stratified by prior surgery 
survexp(stop ~ surgery + ratetable(sex="male", year=year*365.25,  
        age=(age+48)*365.25), conditional=T, data=hearta) 
rm(hearta)