Skip to main content
replaced http://stats.stackexchange.com/ with https://stats.stackexchange.com/
Source Link

In this question and in two other recent questions (herehere and herehere) you are interested in the "slope" that represents the relation of a continuous variable, NE, to survival in a Cox proportional hazards model. You are particularly interested in whether the relation of NE to survival differs between sexes; furthermore, individuals might belong to either of 2 Groups, G1 and G2. I'll assume that linearity with respect to NEand the proportional hazards assumption are both verified. I'll ignore the random-effects term* that you included in other related questions.

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 coefficient, combining 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 squaresType I sums of squares. If the data are reasonably balanced among combinations of covariates (for survival models, in terms of event numbers) then this may provide a useful test provided that you are clear about what it examines. For example, if you specified the following model:

In this question and in two other recent questions (here and here) you are interested in the "slope" that represents the relation of a continuous variable, NE, to survival in a Cox proportional hazards model. You are particularly interested in whether the relation of NE to survival differs between sexes; furthermore, individuals might belong to either of 2 Groups, G1 and G2. I'll assume that linearity with respect to NEand the proportional hazards assumption are both verified. I'll ignore the random-effects term* that you included in other related questions.

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 coefficient, combining 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 may provide a useful test provided that you are clear about what it examines. For example, if you specified the following model:

In this question and in two other recent questions (here and here) you are interested in the "slope" that represents the relation of a continuous variable, NE, to survival in a Cox proportional hazards model. You are particularly interested in whether the relation of NE to survival differs between sexes; furthermore, individuals might belong to either of 2 Groups, G1 and G2. I'll assume that linearity with respect to NEand the proportional hazards assumption are both verified. I'll ignore the random-effects term* that you included in other related questions.

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 coefficient, combining 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 may provide a useful test provided that you are clear about what it examines. For example, if you specified the following model:

rewrote following further explanation of question's intent
Source Link
EdM
  • 101.5k
  • 11
  • 102
  • 303

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 NEand 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.

In this question and in two other recent questions (here and here) you still seem to be treating this Cox regression similarly to a (generalized) linear regression as you look for a "slope" for females in group 1. As explained in my answer to another question, this is incorrect.

The way you have specified your Cox model, the baseline hazard is that for females in group G1 at a value of 0 for your continuous predictor. All the coefficients reported for the Cox model represent differences in the overall slope of the log hazard function from that baseline, assuming proportional hazards for all predictors. There is a danger in calling these Cox coefficients "slopes" as they represent differences in slopes from a baseline log-hazard function.

Thus, I emphasize: There is no "slope" in the Cox regression for females in Group G1. It's unclear why you think that model$coefficients[3] represents such a "slope." It's also hard to validate your attempts to combine coefficients, as it's not clear from your question which numbered coefficients correspond to which variables or interaction terms.

The results you show* directly answer your question of sex-specific differences in the relation of the explanatory variable NE to survival. That is addressed by the SexM:NE interaction term, which is highly significant in this case.

At least for the results you show here, there would be little reason to proceed to evaluating differences with respect to Groups, as there are no significant differences between groups G1 (baseline) and G2 directly or in interaction terms involving them.

If you do wish to combine coefficients for hypothesis testing then you need to take into account the covariances among the coefficients as well as the variances of the individual coefficients. The general rule for the variance of a sum of correlated random variables (the Cox coefficients in this case) is given here. The standard coxph function in R returns a var object that includes both the variances (along the diagonal) and the covariances (off diagonal) of the Cox coefficients; I presume that coxme also does so.

Finally, 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 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 purpose.

In this question and in two other recent questions (here and here) you are interested in the "slope" that represents the relation of a continuous variable, NE, to survival in a Cox proportional hazards model. You are particularly interested in whether the relation of NE to survival differs between sexes; furthermore, individuals might belong to either of 2 Groups, G1 and G2. I'll assume that linearity with respect to NEand the proportional hazards assumption are both verified. I'll ignore the random-effects term* that you included in other related questions.

Much depends on how you want to treat the group membership issue. In the example of this question,** where there is little evidence for differences in outcome with respect to Group G1 versus G2, preliminary data exploration and subject-matter knowledge might suggest that you simply remove the Group variable from your model. Tests of the interaction term SexM:NE would then provide the answer to your question about sex differences with respect to the relation of NE to survival.

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 coefficient, combining 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 may 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

then anova would first associate as much as possible with NE, then with Sex, then with Group, and then test whether the NE:Sex interaction significantly 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 have a particular interest in the 3-way interaction among NE, Sex and Group then you will need to examine contrasts of the coefficients, similar to what you propose but with an important difference in implementation. The test you propose is equivalent to a Wald test. Examining whether there was a difference between males and females with respect to the value of the NE coefficient in Group G2, you would test whether $\beta_{SexM:NE}+\beta_{SexM:GroupG2:NE}$ (MG2-FG2 in your question) is different from 0. As the coefficient 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 (based on the square root of the variance) ignores the covariance of the estimates of the coefficients, which is necessary and is provided by the corresponding off-diagonal element of the variance-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 cph Cox models that allows tests of arbitrary contrasts, including bootstrap non-parametric tests.

One 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 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 demonstration.

Source Link
EdM
  • 101.5k
  • 11
  • 102
  • 303

In this question and in two other recent questions (here and here) you still seem to be treating this Cox regression similarly to a (generalized) linear regression as you look for a "slope" for females in group 1. As explained in my answer to another question, this is incorrect.

The way you have specified your Cox model, the baseline hazard is that for females in group G1 at a value of 0 for your continuous predictor. All the coefficients reported for the Cox model represent differences in the overall slope of the log hazard function from that baseline, assuming proportional hazards for all predictors. There is a danger in calling these Cox coefficients "slopes" as they represent differences in slopes from a baseline log-hazard function.

Thus, I emphasize: There is no "slope" in the Cox regression for females in Group G1. It's unclear why you think that model$coefficients[3] represents such a "slope." It's also hard to validate your attempts to combine coefficients, as it's not clear from your question which numbered coefficients correspond to which variables or interaction terms.

The results you show* directly answer your question of sex-specific differences in the relation of the explanatory variable NE to survival. That is addressed by the SexM:NE interaction term, which is highly significant in this case.

At least for the results you show here, there would be little reason to proceed to evaluating differences with respect to Groups, as there are no significant differences between groups G1 (baseline) and G2 directly or in interaction terms involving them.

If you do wish to combine coefficients for hypothesis testing then you need to take into account the covariances among the coefficients as well as the variances of the individual coefficients. The general rule for the variance of a sum of correlated random variables (the Cox coefficients in this case) is given here. The standard coxph function in R returns a var object that includes both the variances (along the diagonal) and the covariances (off diagonal) of the Cox coefficients; I presume that coxme also does so.

Finally, 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 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 purpose.