Cox regression in subgroups

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:

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?

• 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? Commented Dec 31, 2021 at 21:59
• Dichtomization can make clinical decision making easier. Commented Jan 1, 2022 at 0:00
• Perhaps, but the quality of the decision much much poorer due to the bias imparted. I highly suggest you NOT do this. Commented Jan 1, 2022 at 0:27
• Ok, I will consider not doing it. How about a subgroup analysis of gender? Would the formula be correct in that case? Commented Jan 1, 2022 at 9:58

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.
• Got it. However, getting back to my original question: coxph(Surv(time, status) ~ treatment * covariete data = df) is the right formula then? Commented Jan 2, 2022 at 12:22
• @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.