I ran an analysis in which I used Cox regression to investigate the relationship between a number of predictor variables and time to death. I used R for that: coxph(Surv(time, status) ~ covariate1, data = df). Now, I would like to do a subgroup analysis; e. g. does the effect differ in younger vs. older patients or male vs. female patients and calculate the p-value for interaction, like in this publication:

enter image description here

If age was a column in my dataset which dichtomized the patient age, and treatment the treatment variable, would the following code be correct? coxph(Surv(time, status) ~ treatment * age, data = df). If so, would the p-value under treatment:age be the p-value for interaction?

  • 2
    $\begingroup$ Dichotomization is known to cause bias and should be avoided. Why would you do this and not just estimate an interaction between treatment and continuous age? $\endgroup$ Dec 31, 2021 at 21:59
  • $\begingroup$ Dichtomization can make clinical decision making easier. $\endgroup$
    – Takanashi
    Jan 1 at 0:00
  • $\begingroup$ Perhaps, but the quality of the decision much much poorer due to the bias imparted. I highly suggest you NOT do this. $\endgroup$ Jan 1 at 0:27
  • $\begingroup$ Ok, I will consider not doing it. How about a subgroup analysis of gender? Would the formula be correct in that case? $\endgroup$
    – Takanashi
    Jan 1 at 9:58

1 Answer 1


Interaction terms are a standard way to examine whether some effect of interest differs depending on the value of a covariate. Then the coefficient of the interaction term indicates the magnitude of the difference with respect to the covariate and its p-value indicates the nominal "significance." That's true for all regression models. (With "relative risk" rather than "hazard ratio" values reported in your example, that study might have used binomial regressions rather than Cox survival models.)

Some warnings, however, based on the example you cite. With only 55 events one shouldn't be trying to fit more than 3 to 5 coefficients for predictors, including their interaction terms, in a model lest one risks overfitting. It looks like the authors of your example did 10 separate treatment*covariate interaction models, each of which had 3 such coefficients. Each of those models necessarily ignored the values of all the other covariates, so many of the apparent covariate effects might just represent differences in prevalence of true outcome-associated covariates between the indicated groups.

It's also not clear that the authors (a) took the multiple comparisons into account in their p-value computations or (b) had much power to find true interactions with so few events. Add that to Demetri's wise caution about dichotomizing continuous predictors, and I'd be reluctant for you to use that particular paper as a guide to your work.

With Cox models to evaluate a treatment effect it's usually best to include all covariates that are reasonably expected to be associated with outcome in a single model. If you have too few events for the number of covariates for which you wish to control, you can use penalization on those covariates (e.g., ridge regression) while not penalizing the treatment effect itself. See Chapter 4 of Frank Harrell's book or course notes, in particular section 4.12.2 on "Developing Models for Effect Estimation."

  • $\begingroup$ Got it. However, getting back to my original question: coxph(Surv(time, status) ~ treatment * covariete data = df) is the right formula then? $\endgroup$
    – Takanashi
    Jan 2 at 12:22
  • 1
    $\begingroup$ @Takanashi that's the standard way to code an interaction term along with both "main effects" in R (which is best practice when incorporating interactions). It expands to treatment + covariate + treatment:covariate. Note that software-specific questions are off-topic on this site; my answer necessarily focused on the statistical issues that your question raised. $\endgroup$
    – EdM
    Jan 2 at 16:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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