Contributor
Posts: 50

how to get the p-value of Hazard Ratio for Cox model with interaction using Harzard Ratio statement

Hi,

I tried to get p-value for hazard ratio for a Cox model with interaction term, it seems like Harzard Ratio statement doesn' t provide p-value, must I use estimate statement? Appreicate any input!

Thanks,

Teresa

Super User
Posts: 20,730

Re: how to get the p-value of Hazard Ratio for Cox model with interaction using Harzard Ratio statem

In general for interaction terms you need to specify a level ie AT() and then I thought you did get a P-Value?

What does your code currently look like?

Ideally you can replicate your issue with some sample data, data from the documentation will be fine I just don't feel like mocking up data to test this...or someone else will answer

Contributor
Posts: 50

Re: how to get the p-value of Hazard Ratio for Cox model with interaction using Harzard Ratio statem

Thanks! Here is the example code for proc phreg. The Hazardratio were used to compute hazard ratio, but p-value will not be displayed in the output. is there any option for Harzardratio statement can provide p-value?

data testp;
input val trt censor var1 var2;
datalines;
3 1 0 2 2
18.9 1 1 1 5
3.6 1 0 2 2
6.5 1 0 2 7
13.5 1 1 1 4
11 1 1 1 1
3.8 1 0 2 3
3.8 1 1 2 4
10.5 1 0 2 3
2.3 1 0 1 8
3.1 1 0 2 6
2.3 1 0 2 2
1 2 1 1 2
3.7 2 1 2 5
7.8 2 1 2 7
2.4 2 0 2 9
2.5 2 1 2 5
6.8 2 0 1 3
6.3 2 0 2 4
2.4 2 1 1 3
1.7 2 0 2 6
7.8 2 0 2 8
16.4 2 1 1 3
3.8 2 0 2 2

;
run;
proc print; run;

proc phreg data=testp;
class trt(ref="2") ;
model aval*censor(1) = trt var2 trt*var2/rl ties=efron ;
hazardratio 'var2' var2/units=10 cl=both;
hazardratio 'trt' trt/ at(var2=1) cl=both alpha=0.10;

run;

Super User
Posts: 20,730

Re: how to get the p-value of Hazard Ratio for Cox model with interaction using Harzard Ratio statem

The P-Value comes from the ParameterEstimates table.

Or am I missing something?

Contributor
Posts: 50

Re: how to get the p-value of Hazard Ratio for Cox model with interaction using Harzard Ratio statem

if interaction term is involved, it only provides the p-value for coefficient estimate. Hazard ratio would be provided in parameterEstimates table.
Super User
Posts: 20,730

Re: how to get the p-value of Hazard Ratio for Cox model with interaction using Harzard Ratio statem

Isn't the HazardRatio the exp(parameterEstimate) especially if Referential coding is used - which you aren't by the way. It's typically how models are run so just making a note of this.

I do think the p-value of the parameter estimate is the same as the hazard ratio, it's a bit tricky to see in your example because you only have two trt. If you have 3, you see that interaction term generates one for each level of your categorical variable to match.

I'll move your question to the Statistical Procedures forum and maybe one of the other more knowledgeable stat's guru's can chime in and correct me

Hazard Ratio calcs according to SAS:

https://support.sas.com/documentation/cdl/en/statug/63033/HTML/default/viewer.htm#statug_phreg_sect0...

The alternative is to write your own custom CONTRAST statement but that seems like a pain. It would be one way to check things though.

PS. I spent years doing survival analysis but sadly I've spent more years not so I'm getting too rusty to answer these types of questions anymore

Contributor
Posts: 50

Re: how to get the p-value of Hazard Ratio for Cox model with interaction using Harzard Ratio statem

Thanks, Reeza.

1. I tried param=ref, the estimates are the same.

2. the p-value for coefficient estimate is the same for HR if the interaction of categorical and continuous variables are involved. But the hazard ration is still not displayed in ParameterEstimate table.

3. if interaction of two categorical variables are involved, there will be several HRs for different levels of categorical variables, the p-value won't be the same (only one p-value of coefficient estimate is displayed in the ParameterEstimates table).

4. I really don't like to use Contrast or Estimate, it is indeed a pain. Thanks for moving the question to statistical forum. I hope some other stat staff could chime in.

Contributor
Posts: 50

Re: how to get the p-value of Hazard Ratio for Cox model with interaction using Harzard Ratio statem

BTW, this is the code if interaction of two categorical variables is involved.

proc phreg data=testp;
class trt(ref="2") var1(ref="2")/param=ref;
model val*censor(1) = trt var1 trt*var1/rl ties=efron ;

hazardratio 'var1' var1/diff=ref at(trt='1') cl=both;
hazardratio 'var1' var1/diff=ref at(trt='2') cl=both;

hazardratio 'trt' trt/diff=ref at(var1='1') cl=both;
hazardratio 'trt' trt/diff=ref at(var1='2') cl=both;

run;
Super User
Posts: 20,730

Re: how to get the p-value of Hazard Ratio for Cox model with interaction using Harzard Ratio statem

jojo wrote:

Thanks, Reeza.

1. I tried param=ref, the estimates are the same.

2. the p-value for coefficient estimate is the same for HR if the interaction of categorical and continuous variables are involved. But the hazard ration is still not displayed in ParameterEstimate table.

3. if interaction of two categorical variables are involved, there will be several HRs for different levels of categorical variables, the p-value won't be the same (only one p-value of coefficient estimate is displayed in the ParameterEstimates table).

4. I really don't like to use Contrast or Estimate, it is indeed a pain. Thanks for moving the question to statistical forum. I hope some other stat staff could chime in.

Is #3 correct? Try adding some more levels to your data to see. In your example all your variables are binary so you only need 1 level, but if more are involved there are more estimates in the table.

Contributor
Posts: 50

Re: how to get the p-value of Hazard Ratio for Cox model with interaction using Harzard Ratio statem

I added one level to var1, it is three levels categorical variable now.

If the reference group of one categorical variable in the interaction term, HR is just exp(coefficient estimate of the interaction term) in the ParameterEstimate, but for the interaction term that both categorical are non-reference group, the HR calc involved the coefficient of main effect estimate in the ParamerEstimate table, p-value will not be the same as the p-value for the coefficient of the interaction term (attached the output here). Let me know if I am wrong.

data testp;
input val trt censor var1 var2;
datalines;
3 1 0 2 2
18.9 1 1 1 5
3.6 1 0 2 2
6.5 1 0 3 7
13.5 1 1 1 4
11 1 1 1 1
3.8 1 0 2 3
3.8 1 1 2 4
10.5 1 0 2 3
2.3 1 0 1 8
3.1 1 0 2 6
2.3 1 0 3 2
1 2 1 1 2
3.7 2 1 2 5
7.8 2 1 3 7
2.4 2 0 3 9
2.5 2 1 2 5
6.8 2 0 1 3
6.3 2 0 2 4
2.4 2 1 1 3
1.7 2 0 2 6
7.8 2 0 3 8
16.4 2 1 1 3
3.8 2 0 2 2

;
run;
proc print; run;

proc phreg data=testp;
class trt(ref="2")/param=ref ;
model val*censor(1) = trt var2 trt*var2/rl ties=efron ;
hazardratio 'var2' var2/units=10 cl=both;
hazardratio 'trt' trt/ at(var2=1) cl=both alpha=0.10;

run;

ods output ParameterEstimates=est;
proc phreg data=testp;
class trt(ref="2") var1(ref="2")/param=ref;
model val*censor(1) = trt var1 trt*var1/rl ties=efron ;

hazardratio 'var1' var1/diff=ref at(trt='1') cl=both;
hazardratio 'var1' var1/diff=ref at(trt='2') cl=both;

hazardratio 'trt' trt/diff=ref at(var1='1') cl=both;
hazardratio 'trt' trt/diff=ref at(var1='2') cl=both;

run;

data est1;
set est;
exp_est = exp(estimate);
run;

proc print data = est1; run;

Discussion stats
• 9 replies
• 766 views
• 0 likes
• 2 in conversation