0
$\begingroup$

How to get the Hazard Ratios in each level of the subgroup variable? For example, in my example below, I want to get HR/(95% CI) in male patients (treatment effect of arm1 to arm 2 in male patients) and HR/(95% CI) in female patients (treatment effect of arm 1 to arm 2 in female patients).

I read a discussion and it was suggested to include an interaction term, better than subsetting the data. But I do not see how to get HRs in each subset of patients.

enter image description here

What I want is like in the forest plot, HR of the two treatment arms in one category, and another category:

enter image description here

Does the following code make sense? enter image description here

$\endgroup$
4
  • $\begingroup$ There are not 2 HRs. One of the sexes will be the reference value and there will be a coefficient for the other sex. You will be able to calculate predicted survival for each value of sex if you fix the values of the other variables to a particular level. $\endgroup$
    – DWin
    Commented Oct 21 at 19:50
  • $\begingroup$ The hazard ratio for males compares the hazard in men to the hazard in women. If you want the hazard ratio for women compared to men, then just invert it, or-rerun your model with the factor levels round the other way. Or am I misunderstanding what you are asking? $\endgroup$ Commented Oct 21 at 20:01
  • $\begingroup$ If you need help interpreting results from statistical models, you should ask for help at Cross Validated instead. You are likely to get better help there. This is not really a specific programming question that's appropriate for Stack Overflow. $\endgroup$
    – MrFlick
    Commented Oct 21 at 20:02
  • $\begingroup$ there is misunderstanding what I want. I want to calculate the HR of treatment arm 1 to treatment arm 2 in male patients, and HR of treatment arm 1 vs arm 2 in female patients, respectively. $\endgroup$
    – ziweiguan
    Commented Oct 21 at 21:14

1 Answer 1

1
$\begingroup$

An interaction term or its equivalent is needed to get within-subgroup hazard ratios. Your model with an interaction between treatment and sex implicitly assumes that the shape of the baseline hazard is the same for both sexes, however. An alternative could be to stratify by sex and do an interaction of treatment with the strata (e.g., treatment*strata(sex)). That allows for different baseline hazard shapes between sexes and would directly provide separate hazard ratios for each sex. If you really only have treatment and sex as predictors in the model then that would be equivalent to subgroup analysis, but if there are other predictors (as I hope that there are) then you get the advantages of a comprehensive model.

I haven't gone through the code in detail, and coding per se is off-topic on this site. A quick glance suggests that the code doesn't do what you intend. When there are multiple coefficients involved, as are needed to get treatment-associated hazard ratios for a non-reference level of a predictor involved in an interaction, you need to use the formula for the variance of a weighted sum of correlated variables to get correct standard errors or confidence intervals. That requires use of the variance-covariance matrix of coefficient estimates (vcov() function). I'd recommend that you use vetted software that can do that for you, like that in the rms package (very useful for survival analysis, once you learn how to use it) or the emmeans package.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.