1.17.0
User Documentation for Apache MADlib
cox_prop_hazards.sql_in File Reference

SQL functions for cox proportional hazards. More...

Functions

float8 [] array_avg_transition (float8[] state, float8[] x, boolean use_abs)
 
float8 [] array_avg_merge (float8[] left, float8[] right)
 
float8 [] array_avg_final (float8[] state)
 
aggregate float8 [] array_avg (float8[], boolean)
 
void coxph_train (varchar source_table, varchar output_table, varchar dependent_varname, varchar independent_varname, varchar right_censoring_status, varchar strata, varchar optimizer_params)
 Compute cox-regression coefficients and diagnostic statistics. More...
 
varchar coxph_train ()
 
varchar coxph_train (varchar message)
 
void coxph_train (varchar source_table, varchar output_table, varchar dependent_variable, varchar independent_variable, varchar right_censoring_status, varchar strata)
 Cox regression training function. More...
 
void coxph_train (varchar source_table, varchar output_table, varchar dependent_variable, varchar independent_variable, varchar right_censoring_status)
 Cox regression training function. More...
 
void coxph_train (varchar source_table, varchar output_table, varchar dependent_variable, varchar independent_variable)
 Cox regression training function. More...
 
void coxph_predict (text model_table, text source_table, text id_col_name, text output_table, text pred_type, text reference)
 Predict the linear Predictor or the risk for the given data. More...
 
void coxph_predict (text model_table, text source_table, text id_col_name, text output_table, text pred_type)
 
void coxph_predict (text model_table, text source_table, text id_col_name, text output_table)
 
float8 _coxph_predict_resp (float8[] coef, float8[] col_ind_var, float8[] mean_ind_var, text pred_type)
 
float8 [] _coxph_predict_terms (float8[] coef, float8[] col_ind_var, float8[] mean_ind_var)
 
varchar coxph_predict (varchar message)
 
varchar coxph_predict ()
 
float8 [] _split_transition (float8[], float8, integer, integer)
 
float8 [] _split_merge (float8[], float8[])
 
float8 [] _split_final (float8[])
 
aggregate float8 [] _compute_splits (float8, integer, integer)
 
integer _compute_grpid (float8[] splits, float8 split_col, boolean reverse)
 
integer _compute_grpid (float8[] splits, float8 split_col)
 
coxph_result compute_coxph_result (float8[] coef, float8 l, float8[] d2l, integer niter, float8[] stds)
 
coxph_step_result coxph_improved_step_final (float8[] state)
 
float8 [] coxph_improved_step_transition (float8[] state, float8[] x, float8[] y, integer[] status, float8[] coef, float8[] max_coef)
 
float8 [] coxph_step_inner_final (float8[] state)
 
float8 [] coxph_step_outer_transition (float8[] state1, float8[] state2)
 
coxph_step_result coxph_improved_strata_step_final (float8[] state)
 
aggregate float8 [] coxph_improved_strata_step_outer (float8[] state)
 
void cox_zph (varchar coxph_model_table, varchar output_table)
 Test the proportional hazards assumption for a Cox regression model fit (coxph_train) More...
 
varchar cox_zph ()
 
varchar cox_zph (varchar message)
 
float8 [] __zph_transition (float8[] state, float8[] x, float8[] coef)
 
float8 [] __zph_merge (float8[] left_state, float8[] right_state)
 
float8 [] __zph_final (float8[] left_state)
 
aggregate float8 [] zph_agg (float8[] x, float8[] coef)
 
float8 [] __coxph_scale_resid (integer m, float8[] hessian, float8[] resid)
 
float8 [] __array_elem_corr_transition (float8[] state, float8[] x, float8 y)
 
float8 [] __array_elem_corr_merge (float8[] left_state, float8[] right_state)
 
float8 [] __array_elem_corr_final (float8[] state)
 
aggregate float8 [] array_elem_corr_agg (float8[] array_input, float8 common_elem)
 
float8 [] __coxph_resid_stat_transition (float8[] state, float8 w, float8[] residual, float8[] hessian, integer m)
 
float8 [] __coxph_resid_stat_merge (float8[] state1, float8[] state2)
 
__cox_resid_stat_result __coxph_resid_stat_final (float8[] state)
 
aggregate float8 [] __coxph_resid_stat_agg (float8 w, float8[] residual, float8[] hessian, integer m)
 
void cox_prop_hazards (varchar source_table, varchar out_table, varchar dependent_varname, varchar independent_varname, varchar status)
 Cox regression training function. More...
 
void cox_prop_hazards (varchar source_table, varchar out_table, varchar dependent_variable, varchar independent_variable)
 Cox regression training function. More...
 
varchar cox_prop_hazards (varchar usage_string)
 
varchar cox_prop_hazards ()
 
cox_prop_hazards_result cox_prop_hazards_regr (varchar source, varchar indepColumn, varchar depColumn, varchar status, integer maxNumIterations=20, varchar optimizer="newton", float8 precision=0.0001)
 
cox_prop_hazards_result cox_prop_hazards_regr (varchar source, varchar indepColumn, varchar depColumn, varchar status)
 
cox_prop_hazards_result cox_prop_hazards_regr (varchar source, varchar indepColumn, varchar depColumn, varchar status, integer maxNumIterations)
 
cox_prop_hazards_result cox_prop_hazards_regr (varchar source, varchar indepColumn, varchar depColumn, varchar status, integer maxNumIterations, varchar optimizer)
 
float8 [] __array_element_min (float8[], float8[])
 
aggregate float8 [] array_element_min (float8[])
 
float8 [] __array_element_max (float8[], float8[])
 
aggregate float8 [] array_element_max (float8[])
 

Detailed Description

Date
July 2012
See also
For a brief introduction to cox regression, see the module description Cox-Proportional Hazards Regression

Function Documentation

◆ __array_elem_corr_final()

float8 [] __array_elem_corr_final ( float8 []  state)

◆ __array_elem_corr_merge()

float8 [] __array_elem_corr_merge ( float8 []  left_state,
float8 []  right_state 
)

◆ __array_elem_corr_transition()

float8 [] __array_elem_corr_transition ( float8 []  state,
float8 []  x,
float8  y 
)

◆ __array_element_max()

float8 [] __array_element_max ( float8  [],
float8  [] 
)

◆ __array_element_min()

float8 [] __array_element_min ( float8  [],
float8  [] 
)

◆ __coxph_resid_stat_agg()

aggregate float8 [] __coxph_resid_stat_agg ( float8  w,
float8 []  residual,
float8 []  hessian,
integer  m 
)

◆ __coxph_resid_stat_final()

__cox_resid_stat_result __coxph_resid_stat_final ( float8 []  state)

◆ __coxph_resid_stat_merge()

float8 [] __coxph_resid_stat_merge ( float8 []  state1,
float8 []  state2 
)

◆ __coxph_resid_stat_transition()

float8 [] __coxph_resid_stat_transition ( float8 []  state,
float8  w,
float8 []  residual,
float8 []  hessian,
integer  m 
)

◆ __coxph_scale_resid()

float8 [] __coxph_scale_resid ( integer  m,
float8 []  hessian,
float8 []  resid 
)

◆ __zph_final()

float8 [] __zph_final ( float8 []  left_state)

◆ __zph_merge()

float8 [] __zph_merge ( float8 []  left_state,
float8 []  right_state 
)

◆ __zph_transition()

float8 [] __zph_transition ( float8 []  state,
float8 []  x,
float8 []  coef 
)

◆ _compute_grpid() [1/2]

integer _compute_grpid ( float8 []  splits,
float8  split_col,
boolean  reverse 
)

◆ _compute_grpid() [2/2]

integer _compute_grpid ( float8 []  splits,
float8  split_col 
)

◆ _compute_splits()

aggregate float8 [] _compute_splits ( float8  ,
integer  ,
integer   
)

◆ _coxph_predict_resp()

float8 _coxph_predict_resp ( float8 []  coef,
float8 []  col_ind_var,
float8 []  mean_ind_var,
text  pred_type 
)

◆ _coxph_predict_terms()

float8 [] _coxph_predict_terms ( float8 []  coef,
float8 []  col_ind_var,
float8 []  mean_ind_var 
)

◆ _split_final()

float8 [] _split_final ( float8  [])

◆ _split_merge()

float8 [] _split_merge ( float8  [],
float8  [] 
)

◆ _split_transition()

float8 [] _split_transition ( float8  [],
float8  ,
integer  ,
integer   
)

◆ array_avg()

aggregate float8 [] array_avg ( float8  [],
boolean   
)

◆ array_avg_final()

float8 [] array_avg_final ( float8 []  state)

◆ array_avg_merge()

float8 [] array_avg_merge ( float8 []  left,
float8 []  right 
)

◆ array_avg_transition()

float8 [] array_avg_transition ( float8 []  state,
float8 []  x,
boolean  use_abs 
)

◆ array_elem_corr_agg()

aggregate float8 [] array_elem_corr_agg ( float8 []  array_input,
float8  common_elem 
)

◆ array_element_max()

aggregate float8 [] array_element_max ( float8  [])

◆ array_element_min()

aggregate float8 [] array_element_min ( float8  [])

◆ compute_coxph_result()

coxph_result compute_coxph_result ( float8 []  coef,
float8  l,
float8 []  d2l,
integer  niter,
float8 []  stds 
)

◆ cox_prop_hazards() [1/4]

void cox_prop_hazards ( varchar  source_table,
varchar  out_table,
varchar  dependent_varname,
varchar  independent_varname,
varchar  status 
)

◆ cox_prop_hazards() [2/4]

void cox_prop_hazards ( varchar  source_table,
varchar  out_table,
varchar  dependent_variable,
varchar  independent_variable 
)

◆ cox_prop_hazards() [3/4]

varchar cox_prop_hazards ( varchar  usage_string)

◆ cox_prop_hazards() [4/4]

varchar cox_prop_hazards ( )

◆ cox_prop_hazards_regr() [1/4]

cox_prop_hazards_result cox_prop_hazards_regr ( varchar  source,
varchar  indepColumn,
varchar  depColumn,
varchar  status,
integer  maxNumIterations = 20,
varchar  optimizer = "newton",
float8  precision = 0.0001 
)

◆ cox_prop_hazards_regr() [2/4]

cox_prop_hazards_result cox_prop_hazards_regr ( varchar  source,
varchar  indepColumn,
varchar  depColumn,
varchar  status 
)

◆ cox_prop_hazards_regr() [3/4]

cox_prop_hazards_result cox_prop_hazards_regr ( varchar  source,
varchar  indepColumn,
varchar  depColumn,
varchar  status,
integer  maxNumIterations 
)

◆ cox_prop_hazards_regr() [4/4]

cox_prop_hazards_result cox_prop_hazards_regr ( varchar  source,
varchar  indepColumn,
varchar  depColumn,
varchar  status,
integer  maxNumIterations,
varchar  optimizer 
)

◆ cox_zph() [1/3]

void cox_zph ( varchar  coxph_model_table,
varchar  output_table 
)
Parameters
coxph_model_tableName of the table that contains the Cox Proportional Hazards model
output_tableName of the output table to contain the statistics to test the proportional hazards assumption
Returns
An output table with following columns: Columns of the matrix contain the correlation coefficient between transformed , a chi-square, and the two-sided p-value.
  • rho FLOAT8[] - Array of correlation coefficient between survival time and the scaled Schoenfeld residuals
  • chi_square FLOAT8[] - Chi-square test statistic for the
  • p_value FLOAT8[] - Two-side p-value for the chi-square test

◆ cox_zph() [2/3]

varchar cox_zph ( )

◆ cox_zph() [3/3]

varchar cox_zph ( varchar  message)

◆ coxph_improved_step_final()

coxph_step_result coxph_improved_step_final ( float8 []  state)

◆ coxph_improved_step_transition()

float8 [] coxph_improved_step_transition ( float8 []  state,
float8 []  x,
float8 []  y,
integer []  status,
float8 []  coef,
float8 []  max_coef 
)

◆ coxph_improved_strata_step_final()

coxph_step_result coxph_improved_strata_step_final ( float8 []  state)

◆ coxph_improved_strata_step_outer()

aggregate float8 [] coxph_improved_strata_step_outer ( float8 []  state)

◆ coxph_predict() [1/5]

void coxph_predict ( text  model_table,
text  source_table,
text  id_col_name,
text  output_table,
text  pred_type,
text  reference 
)
Parameters
model_tableName of the table containing the cox model.
source_tableName of the table containing the prediction data.
output_tableName of the table to store the prediction results into.
pred_typeType of prediction. Can be one of 'linear_predictors', 'risk' or 'terms'.
referenceReference level to use for centering predictions. Can be one of 'overall' or 'strata'.

◆ coxph_predict() [2/5]

void coxph_predict ( text  model_table,
text  source_table,
text  id_col_name,
text  output_table,
text  pred_type 
)

◆ coxph_predict() [3/5]

void coxph_predict ( text  model_table,
text  source_table,
text  id_col_name,
text  output_table 
)

◆ coxph_predict() [4/5]

varchar coxph_predict ( varchar  message)

◆ coxph_predict() [5/5]

varchar coxph_predict ( )

◆ coxph_step_inner_final()

float8 [] coxph_step_inner_final ( float8 []  state)

◆ coxph_step_outer_transition()

float8 [] coxph_step_outer_transition ( float8 []  state1,
float8 []  state2 
)

◆ coxph_train() [1/6]

void coxph_train ( varchar  source_table,
varchar  output_table,
varchar  dependent_varname,
varchar  independent_varname,
varchar  right_censoring_status,
varchar  strata,
varchar  optimizer_params 
)

To include an intercept in the model, set one coordinate in the independentVariables array to 1.

Parameters
source_tableName of the source relation containing the training data
output_tableName of the output relation to contain the coxph_train model
independent_varnameName of the independent column
dependent_varnameName of the dependent column measuring time of death
right_censoring_statusName of the column that determines right censoring support
strataComma-separated list of column names on which to stratify the data
optimizer_paramsComma-separated list of parameters for the optimizer function
Returns
An output table with following columns:
  • coef FLOAT8[] - Array of coefficients, \( \boldsymbol \beta \)
  • log_likelihood FLOAT8 - Log-likelihood \(l(\boldsymbol \beta)\)
  • std_err FLOAT8[] - Array of standard errors, \( \mathit{se}(c_1), \dots, \mathit{se}(c_k) \)
  • z_stats FLOAT8[] - Array of Wald z-statistics, \( \boldsymbol z \)
  • p_values FLOAT8[] - Array of Wald p-values, \( \boldsymbol p \)
  • hessian FLOAT8[] - Hessian Matrix
  • num_iterations INTEGER - The number of iterations before the algorithm terminated
  • Get vector of coefficients \( \boldsymbol \beta \) and all diagnostic statistics:
    SELECT coxph_train(
       'source_table', 'output_table',
       'dependent_varname', 'independent_varname'
       'right_censoring_status', 'strata'
    );
  • Get vector of coefficients \( \boldsymbol \beta \):
    SELECT coef from output_table

See Cox-Proportional Hazards Regression for more details.

◆ coxph_train() [2/6]

varchar coxph_train ( )

◆ coxph_train() [3/6]

varchar coxph_train ( varchar  message)

◆ coxph_train() [4/6]

void coxph_train ( varchar  source_table,
varchar  output_table,
varchar  dependent_variable,
varchar  independent_variable,
varchar  right_censoring_status,
varchar  strata 
)

◆ coxph_train() [5/6]

void coxph_train ( varchar  source_table,
varchar  output_table,
varchar  dependent_variable,
varchar  independent_variable,
varchar  right_censoring_status 
)

◆ coxph_train() [6/6]

void coxph_train ( varchar  source_table,
varchar  output_table,
varchar  dependent_variable,
varchar  independent_variable 
)

◆ zph_agg()

aggregate float8 [] zph_agg ( float8 []  x,
float8 []  coef 
)