Description
The CoxHazardRatio function takes as input the coefficient tbl_teradata
generated by the function CoxPH (td_coxph_mle
) and outputs the hazard ratios between
predictive features and either their corresponding reference features
or their unit differences.
Usage
td_cox_hazard_ratio_mle (
object = NULL,
predicts = NULL,
refs = NULL,
predict.feature.names = NULL,
predict.feature.columns = NULL,
predict.feature.units.columns = NULL,
ref.feature.columns = NULL,
accumulate = NULL,
object.sequence.column = NULL,
predicts.sequence.column = NULL,
refs.sequence.column = NULL,
predicts.partition.column = "1",
refs.partition.column = "1",
object.order.column = NULL,
predicts.order.column = NULL,
refs.order.column = NULL
)
Arguments
object |
Required Argument. |
object.order.column |
Optional Argument. |
predicts |
Required Argument. |
predicts.partition.column |
Optional Argument. |
predicts.order.column |
Optional Argument. |
refs |
Optional Argument. |
refs.partition.column |
Optional Argument. |
refs.order.column |
Optional Argument. |
predict.feature.names |
Required Argument. |
predict.feature.columns |
Optional Argument. |
predict.feature.units.columns |
Optional Argument. |
ref.feature.columns |
Optional Argument. |
accumulate |
Optional Argument. |
object.sequence.column |
Optional Argument. |
predicts.sequence.column |
Optional Argument. |
refs.sequence.column |
Optional Argument. |
Value
Function returns an object of class "td_cox_hazard_ratio_mle" which
is a named list containing object of class "tbl_teradata".
Named list member can be referenced directly with the "$" operator
using name: result.
Examples
# Get the current context/connection
con <- td_get_context()$connection
# Load example data.
loadExampleData("coxhazardratio_example", "lc_new_reference", "lc_new_predictors")
loadExampleData("coxph_example", "lungcancer")
# Create object(s) of class "tbl_teradata".
lungcancer <- tbl(con, "lungcancer")
# Input table lc_new_predictors is a list of four patients who have been
# diagnosed with lung cancer.
lc_new_predictors <- tbl(con,"lc_new_predictors")
# Generate model table.
td_coxph_out <- td_coxph_mle(data = lungcancer,
feature.columns = c("trt","celltype","karno","diagtime","age","prior"),
time.interval.column = "time_int",
event.column = "status",
categorical.columns = c("trt","celltype","prior")
)
# Example 1 - No Reference Values Provided.
# This example calculates four hazard ratios for each patient,
# using individual patient characteristics as a reference.
td_cox_hazard_ratio_out1 <- td_cox_hazard_ratio_mle(object = td_coxph_out$coefficient.table,
predicts = lc_new_predictors,
predict.feature.names = c("trt", "celltype", "karno",
"diagtime", "age", "prior"),
predict.feature.columns = c("trt", "celltype", "karno",
"diagtime", "age", "prior"),
accumulate = c("id", "name")
)
# Example 2: Partition by Name/ID and No Reference Values
td_cox_hazard_ratio_out2 <- td_cox_hazard_ratio_mle(object = td_coxph_out$coefficient.table,
predicts = lc_new_predictors,
predicts.partition.column=c("id", "name"),
predict.feature.names = c("trt", "celltype", "karno",
"diagtime", "age" ,"prior"),
predict.feature.columns = c("trt", "celltype", "karno",
"diagtime", "age", "prior"),
accumulate = c("id", "name")
)
# Example 3: Use Reference Values
# Each of the four new patients in the table lc_new_predictors are compared with each of
# the attribute reference values provided in the table lc_new_reference, and a hazard ratio
# is calculated.
lc_new_reference <- tbl(con,"lc_new_reference")
td_cox_hazard_ratio_out3 <- td_cox_hazard_ratio_mle(object=td_coxph_out$coefficient.table,
predicts=lc_new_predictors,
refs=lc_new_reference,
predict.feature.columns=c('trt', 'celltype', 'karno',
'diagtime', 'age', 'prior'),
ref.feature.columns=c('trt', 'celltype', 'karno',
'diagtime', 'age', 'prior'),
predict.feature.names=c('trt', 'celltype', 'karno',
'diagtime', 'age', 'prior'),
accumulate = c("id", "name")
)
# Example 4: Use Reference values and Partition by id
# In this example, the new patients in the input table lc_new_predictors
# are compared with the reference table using partition by id.
# The hazard ratio is calculated only when the patient's id matches the reference id.
td_cox_hazard_ratio_out4 <- td_cox_hazard_ratio_mle(object=td_coxph_out$coefficient.table,
predicts=lc_new_predictors,
predicts.partition.column='id',
refs=lc_new_reference,
refs.partition.column='id',
predict.feature.columns=c('trt', 'celltype', 'karno',
'diagtime', 'age', 'prior'),
ref.feature.columns=c('trt', 'celltype', 'karno',
'diagtime', 'age', 'prior'),
predict.feature.names=c('trt', 'celltype', 'karno',
'diagtime', 'age', 'prior'),
accumulate = c("id", "name")
)
# Example 5: Use Units Values
# This example increases the variable karno by 10%, decreases the variable age by
# 10%, leaves the variable diagtime unchanged, and calculates the hazard ratios.
lc_new_predictors_2 <- lc_new_predictors %>% transmute(id, name, karno = karno * 1.1,
diagtime = diagtime * 1, age = age * (0.9))
td_cox_hazard_ratio_out5 <- td_cox_hazard_ratio_mle(object=td_coxph_out$coefficient.table,
predicts=lc_new_predictors_2,
predict.feature.names=c('karno','diagtime','age'),
predict.feature.units.columns=c('karno','diagtime',
'age'),
accumulate = c("id", "name")
)