In this question and in two other recent questions (here and here) you still seem to be treating this Cox regression similarly toare interested in the "slope" that represents the relation of a continuous variable, (generalized) linear regression as you look for a "slope" for femalesNE
, to survival in group 1a Cox proportional hazards model. As explainedYou are particularly interested in whether the relation of my answer to another questionNE
to survival differs between sexes; furthermore, this is incorrectindividuals might belong to either of 2 Groups, G1
and G2
. I'll assume that linearity with respect to NE
and the proportional hazards assumption are both verified. I'll ignore the random-effects term* that you included in other related questions.
The wayMuch depends on how you have specified your Cox model,want to treat the baseline hazard is that for females in group G1 at a value of 0 for your continuous predictormembership issue. All the coefficients reported for the Cox model represent differences inIn the overall slopeexample of the log hazard function from that baselinethis question, assuming proportional hazards for all predictors. There** where there is a dangerlittle evidence for differences in calling these Cox coefficients "slopes" as they representoutcome with respect to Group differences in slopes from a baseline log-hazard function.
Thus, I emphasize:G1
versus There is no "slope" in the Cox regression for females in Group G1. It's unclear why you thinkG2
, preliminary data exploration and subject-matter knowledge might suggest that you simply remove the model$coefficients[3]Group
represents such a "slope." It's also hard to validate your attempts to combine coefficients, as it's not clearvariable from your question which numbered coefficients correspond to which variables or interaction termsmodel.
The results you show* directly Tests of the interaction term SexM:NE
would then provide the answer to your question ofabout sex-specific differences inwith respect to the relation of the explanatory variable NE
to survival. That is addressed
If you wish to maintain the breakdown by Group
, you might consider using the anova
wrapper for the Cox model output in R to provide a single test of the SexM:NE
interaction termcoefficient, which is highly significantcombining information from both Groups. The anova
function performs a hierarchical test of coefficients in the order of entry into the model, using the equivalent of Type I sums of squares. If the data are reasonably balanced among combinations of covariates (for survival models, in terms of event numbers) then this casemay provide a useful test provided that you are clear about what it examines. For example, if you specified the following model:
Surv(time,status)~ NE + Sex + Group + NE:Sex + NE:Group + Sex:Group + NE:Sex:Group
At least for the results you show here, therethen anova
would be little reason to proceed to evaluating differencesfirst associate as much as possible with respect to GroupsNE
, as there are no significant differences between groups G1then with (baseline)Sex
, then with Group
, and G2 directly or inthen test whether the NE:Sex
interaction terms involving themsignificantly explained any residual. Note that this is a different way of evaluating the results of the model from the treatment-contrasts summaries provided by print
or summary
that you display above, even though it is based on the same model.
If you do wish to combine coefficients for hypothesis testinghave a particular interest in the 3-way interaction among NE
, Sex
and Group
then you will need to take into account the covariances among the coefficients as well as the variancesexamine contrasts of the individual coefficients, similar to what you propose but with an important difference in implementation. The general rule for the variance of a sum of correlated random variables (the Cox coefficients in this case)test you propose is givenequivalent to a hereWald test. The standardExamining whether there was a difference between males and females with respect to the value of the coxphNE
functioncoefficient in R returns aGroup G2, you would test whether $\beta_{SexM:NE}+\beta_{SexM:GroupG2:NE}$ (varMG2-FG2
object that includes bothin your question) is different from 0. As the variancescoefficient estimates are correlated, you need the variance of a sum of correlated variables, which in this example is:
$$ \mathop{\rm var}(\beta_{SexM:NE})+\mathop{\rm var}(\beta_{SexM:GroupG2:NE}) + 2\mathop{\rm cov}(\beta_{SexM:NE},\beta_{SexM:GroupG2:NE})$$
Your proposed Z-test (alongbased on the diagonalsquare root of the variance) ignores the covariance of the estimates of the coefficients, which is necessary and is provided by the covariances (off diagonal)corresponding off-diagonal element of the Cox coefficients; I presumevariance-covariance matrix, which you can get from the vcov
function applied to your model. If you use the rms
package, then there is a contrast
function for that package's coxmecph
also does soCox models that allows tests of arbitrary contrasts, including bootstrap non-parametric tests.
FinallyOne warning on this approach, however: Terry Therneau, responsible for much of the survival analysis infrastructure in R, has warned in this vignette that the apparent similarity of Cox regression models to linear regression models does not necessarily extend to tests on contrasts of coefficients. Examine those arguments carefully as you proceed.
*In another question you note that you are also evaluating a "random effect" that only has 2 levels. Treating a variable with so few levels as a random effect can be considered inadvisable.
*The**The model results in this question differ from those in other questions you have asked recently on the same general matter. It helps to specify the seed for the random-number generator, e.g., with set.seed()
in R, before you generate your random data, to have reproducible "random" data for this purposedemonstration.