Teradata R Package Function Reference - CoxSurvival - Teradata R Package - Look here for syntax, methods and examples for the functions included in the Teradata R Package.

Teradata® R Package Function Reference

Product
Teradata R Package
Release Number
16.20
Published
February 2020
Language
English (United States)
Last Update
2020-02-28
dita:id
B700-4007
lifecycle
previous
Product Category
Teradata Vantage

Description

The CoxSurvival function takes as input the coefficient and linear prediction tables generated by the function td_coxph_mle and outputs a table of survival probabilities.

Usage

  td_cox_survival_mle (
      object = NULL,
      cox.model.table = NULL,
      predict.table = NULL,
      predict.feature.names = NULL,
      predict.feature.columns = NULL,
      accumulate = NULL,
      cox.model.table.sequence.column = NULL,
      object.sequence.column = NULL,
      predict.table.sequence.column = NULL
  )

Arguments

object

Required Argument.
Specifies the name of the Cox coefficient model table generated by td_coxph_mle function or the tibble object of the coefficients table output by td_coxph_mle function.

cox.model.table

Required Argument.
Specifies the name of the Cox linear predictor model table generated by td_coxph_mle function.

predict.table

Required Argument.
Specifies the name of the predict table, which contains new prediction feature values for survival calculation.

predict.feature.names

Required Argument.
Specifies the names of features in the Cox model.

predict.feature.columns

Required Argument.
Specifies the names of the columns that contain the values for the features in the Cox model, one column name for each feature name. The ith feature name corresponds to the ith column name. For example, consider this pair of arguments: predict.feature.names("name", "age"), predict.feature.columns("c1", "c2"). The predictive values of the feature "name" are in column "c1", and the predictive values of the feature "age" are in column "c2".

accumulate

Optional Argument.
Specifies the names of the columns in "predict.table"" argument that the function copies to the output table.

cox.model.table.sequence.column

Optional Argument.
Specifies the vector of column(s) that uniquely identifies each row of the input argument "cox.model.table". The argument is used to ensure deterministic results for functions which produce results that vary from run to run.

object.sequence.column

Optional Argument.
Specifies the vector of column(s) that uniquely identifies each row of the input argument "object". The argument is used to ensure deterministic results for functions which produce results that vary from run to run.

predict.table.sequence.column

Optional Argument.
Specifies the vector of column(s) that uniquely identifies each row of the input argument "predict.table". The argument is used to ensure deterministic results for functions which produce results that vary from run to run.

Value

Function returns an object of class "td_cox_survival_mle" which is a named list containing Teradata tbl objects.
Named list members can be referenced directly with the "$" operator using following names:

  1. survival.probability

  2. output

Examples

    # Get the current context/connection
    con <- td_get_context()$connection
    
    # Load example data.
    loadExampleData("coxsurvival_example", "lungcancer","lc_new_predictors")
    
    # Create remote tibble objects.
    lungcancer <- tbl(con, "lungcancer")
    lc_new_predictors <- tbl(con, "lc_new_predictors")
    
    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")
                             )
    
    #linear model predictor table and coefficient table that are generated from the td_coxph_mle function 
    #are used to determine the survival probabilities of the new patients.
    # Example 1 - Pass generated coefficient table and linear predictor table as tibbles.
    td_cox_survival_out <- td_cox_survival_mle(object = td_coxph_out$coefficient.table,
                                           cox.model.table = td_coxph_out$linear.predictor.table,
                                           predict.table = 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 - Pass output of td_coxph_mle directly as object argument.
    td_cox_survival_out <- td_cox_survival_mle(object = td_coxph_out,
                                           cox.model.table = td_coxph_out$linear.predictor.table,
                                           predict.table = 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")
                                           )