<p>The simple answer is that Cox PH is a flavor of <a href="https://towardsdatascience.com/understanding-multiple-regression-249b16bde83e" rel="nofollow noreferrer">multiple regressio</a>n. Multiple regression does indeed try to subtract off the estimated effect of each covariate and look for associations of all other independent variables. Whether this works well in practice is anyone's guess. For a somewhat philosophical high-level discussion see <a href="https://www.edge.org/response-detail/25387" rel="nofollow noreferrer">here</a>.</p>
<p>One notable issue is that &quot;significant&quot; is <a href="https://retractionwatch.com/2019/03/21/time-to-say-goodbye-to-statistically-significant-and-embrace-uncertainty-say-statisticians/#:%7E:text=In%20an%20editorial%20in%20a,it%20and%20don%27t%20use" rel="nofollow noreferrer">not necessarily a great way to think about statistics</a>, according to professional statistical societies. So, like, if a p-value goes up or down a little bit that's kind of expected when you adjust for other variables, it's not really notable. For one thing, it's closely related to questions of <a href="https://machinelearningmastery.com/statistical-power-and-power-analysis-in-python/" rel="nofollow noreferrer">power</a>, driven largely by your sample size.</p>
<p>In simple terms, I would urge you to put all of your data in the model, find some set of independent variables and covariates that you think makes sense <em>before you start analyzing the data</em>, and then build your model accordingly. I don't think that anyone objects to e.g. plotting raw data or model residuals separately in males and females to demonstrate some point, but most associations that are worth caring about will be obvious in a combined dataset.</p>
<p>You <em>can</em> try to explicitly <a href="http://www.utstat.toronto.edu/%7Ebrunner/oldclass/312s19/lectures/312s19PropHazRegWithR2.pdf" rel="nofollow noreferrer">test for an interaction effect in the model</a>. This can be interesting if there's some reason to expect it to be the case, or if there is very compelling evidence that there exists some interaction, but it has the negative of adding to model complexity and further reducing power.</p>

CC BY-SA 4.0
2022-03-03T04:55:50.797Z
2022-03-03T04:55:50.797Z
Maximilian Press
<p>&quot;Under the hood&quot; a Cox model doesn't stratify, consistent with your intuition. It iteratively solves a <a href="https://stats.stackexchange.com/a/560234/28500">partial-likelihood vector score function</a> as a function of regression-coefficient values.</p>
<p>It tries to minimize the sum, over all event times, of the difference between each covariate value for the case having the event and a risk-weighted average of the values for all at risk at that event time. The &quot;risk-weighting&quot; is a function of all current regression-coefficient estimates within an iteration. Iteration continues until regression-coefficient estimates are effectively constant. This nicely handles predictors of all types you might use in a multiple-regression model, including interaction terms, while also allowing for individuals that drop out of the study before experiencing the event.</p>
<p>There thus is nothing to be gained by doing separate models for different groups, as Maximilian Press also says in another answer. Stratified models are often used if the proportional hazards assumption doesn't hold, but those model all the data together and often are structured to provide the same regression-coefficient estimates for all strata while allowing for different baseline survival curves among strata.</p>
<p>I also recommend including as many predictors as possible that you might expect to be associated with outcome in your model, but with one caveat. You risk overfitting if you have fewer than 10-20 <em>events</em> per unpenalized predictor in your model (including levels beyond the first of categorical predictors and any interaction or nonlinear terms). So you might have to make some careful choices or use a penalized approach like ridge regression.</p>
<p>For further information, there are nearly 900 answered questions about Cox models on the <a href="https://stats.stackexchange.com/questions/tagged/cox-model?tab=Active">Cross Validated site</a>.</p>

CC BY-SA 4.0
2022-03-03T17:06:46.930Z
2022-03-03T17:06:46.930Z
EdM
<p>I have read <a href="http://www.sthda.com/english/wiki/cox-proportional-hazards-model" rel="nofollow noreferrer">STDHA</a> and the documentation for the coxph() function in R. I understand that the cox PH model explores how different covariates simultaneously impact survival. Based on the Lung data example in STDHA, a covariate can seem significantly influential in univariate analysis, but not in multivariate analysis. Following the lung data example, &quot;age&quot; is no longer significant in the multivariate cox model.  Quite literally, this means that age does not impact survival when you account for sex and ph.ecog. However, how does the cox PH model evaluate and decide this? Under the hood, does the cox ph model stratify groups by sex, then evaluate if age is still impactful on survival (and then repeat for ph.ecog)? My intuition says no, because I don't think you can do that with continuous variables (so, in turn, how would the model stratify by age and then test if sex still impacts survival)? I don't need a deeply mathematical explanation, as I'm just a coder!</p>
<p>Ultimately, I want to understand if I can run coxph() on the female and male group separately, or if these results would be redundant since we have already added &quot;sex&quot; as a covariate when analyzing all patients.</p>
<p>This is a conceptual question, but please let me know if I can provide any code. If it means anything, I am using surv &amp; survminer in R.</p>

<r><statsmodels>
How Does Cox Proportional Hazard Model Describe Interaction between Covariates
# How Does Cox Proportional Hazard Model Describe Interaction between Covariates

(Asked by: username_0 on 2021-12-28)

I have read [STDHA](http://www.sthda.com/english/wiki/cox-proportional-hazards-model) and the documentation for the coxph() function in R. I understand that the cox PH model explores how different covariates simultaneously impact survival. Based on the Lung data example in STDHA, a covariate can seem significantly influential in univariate analysis, but not in multivariate analysis. Following the lung data example, "age" is no longer significant in the multivariate cox model. Quite literally, this means that age does not impact survival when you account for sex and ph.ecog. However, how does the cox PH model evaluate and decide this? Under the hood, does the cox ph model stratify groups by sex, then evaluate if age is still impactful on survival (and then repeat for ph.ecog)? My intuition says no, because I don't think you can do that with continuous variables (so, in turn, how would the model stratify by age and then test if sex still impacts survival)? I don't need a deeply mathematical explanation, as I'm just a coder!

Ultimately, I want to understand if I can run coxph() on the female and male group separately, or if these results would be redundant since we have already added "sex" as a covariate when analyzing all patients.

This is a conceptual question, but please let me know if I can provide any code. If it means anything, I am using surv & survminer in R.

**Tags:** r, statsmodels

---

## 2 answers

### Answer by username_1 on 2022-03-03. Score: 2

The simple answer is that Cox PH is a flavor of [multiple regressio](https://towardsdatascience.com/understanding-multiple-regression-249b16bde83e)n. Multiple regression does indeed try to subtract off the estimated effect of each covariate and look for associations of all other independent variables. Whether this works well in practice is anyone's guess. For a somewhat philosophical high-level discussion see [here](https://www.edge.org/response-detail/25387).

One notable issue is that "significant" is [not necessarily a great way to think about statistics](https://retractionwatch.com/2019/03/21/time-to-say-goodbye-to-statistically-significant-and-embrace-uncertainty-say-statisticians/#:%7E:text=In%20an%20editorial%20in%20a,it%20and%20don%27t%20use), according to professional statistical societies. So, like, if a p-value goes up or down a little bit that's kind of expected when you adjust for other variables, it's not really notable. For one thing, it's closely related to questions of [power](https://machinelearningmastery.com/statistical-power-and-power-analysis-in-python/), driven largely by your sample size.

In simple terms, I would urge you to put all of your data in the model, find some set of independent variables and covariates that you think makes sense *before you start analyzing the data*, and then build your model accordingly. I don't think that anyone objects to e.g. plotting raw data or model residuals separately in males and females to demonstrate some point, but most associations that are worth caring about will be obvious in a combined dataset.

You *can* try to explicitly [test for an interaction effect in the model](http://www.utstat.toronto.edu/%7Ebrunner/oldclass/312s19/lectures/312s19PropHazRegWithR2.pdf). This can be interesting if there's some reason to expect it to be the case, or if there is very compelling evidence that there exists some interaction, but it has the negative of adding to model complexity and further reducing power.


---

### Answer by username_2 on 2022-03-03. Score: 1

"Under the hood" a Cox model doesn't stratify, consistent with your intuition. It iteratively solves a [partial-likelihood vector score function](https://stats.stackexchange.com/a/560234/28500) as a function of regression-coefficient values.

It tries to minimize the sum, over all event times, of the difference between each covariate value for the case having the event and a risk-weighted average of the values for all at risk at that event time. The "risk-weighting" is a function of all current regression-coefficient estimates within an iteration. Iteration continues until regression-coefficient estimates are effectively constant. This nicely handles predictors of all types you might use in a multiple-regression model, including interaction terms, while also allowing for individuals that drop out of the study before experiencing the event.

There thus is nothing to be gained by doing separate models for different groups, as Maximilian Press also says in another answer. Stratified models are often used if the proportional hazards assumption doesn't hold, but those model all the data together and often are structured to provide the same regression-coefficient estimates for all strata while allowing for different baseline survival curves among strata.

I also recommend including as many predictors as possible that you might expect to be associated with outcome in your model, but with one caveat. You risk overfitting if you have fewer than 10-20 *events* per unpenalized predictor in your model (including levels beyond the first of categorical predictors and any interaction or nonlinear terms). So you might have to make some careful choices or use a penalized approach like ridge regression.

For further information, there are nearly 900 answered questions about Cox models on the [Cross Validated site](https://stats.stackexchange.com/questions/tagged/cox-model?tab=Active).


---

