This example compares each of the four new patients in the table lc_new_predictors with each of the attribute reference values provided in the table lc_new_reference, partitioning by id and calculating the hazard ratio only when the patient id matches the reference id.
Input
- CoxCoeffModel: lungcancer_coef, output by CoxPH Example
- PredictorValues: lc_new_predictors, as in CoxHazardRatio Example: No Reference Values
- ReferenceValues: lc_new_reference, as in CoxHazardRatio Example: Reference Values
SQL Call
SELECT * FROM CoxHazardRatio ( ON lungcancer_coef AS CoxCoeffModel DIMENSION ON lc_new_predictors AS PredictorValues PARTITION BY id ON lc_new_reference AS ReferenceValues PARTITION BY id USING PredictFeatureNames ('trt','celltype','karno','diagtime','age','prior') PredictFeatureColumns ('trt','celltype','karno','diagtime','age','prior') RefFeatureColumns ('trt','celltype','karno','diagtime','age','prior') Accumulate ('id','name') ) AS dt;
Output
Because the input is partitioned, the output table has only 4 rows. The attributes of patient Steffi are similar to those of reference id 4, so her hazard ratio is very close to 1.0 (0.97).
id name trt celltype karno diagtime age prior trt_ref celltype_ref karno_ref diagtime_ref age_ref prior_ref hazardratio -- ------ -------- --------- ----- -------- --- ----- -------- ------------ --------- ------------ ------- --------- ------------------ 3 stella test smallcell 70 3 72 no test smallcell 52 12 61 no 0.502993022637895 2 james standard large 80 12 41 no standard smallcell 54 8 58 no 0.3118815117405267 1 john standard squamous 30 4 63 yes standard squamous 58 12 60 yes 2.4401491013053347 4 steffi test adeno 60 5 63 yes test adeno 60 5 60 yes 0.974218736747829
Download a zip file of all examples and a SQL script file that creates their input tables.