1
$\begingroup$

I'm trying to wrap my head around Cox models as well as how to express them in the form of hazard functions when you have both categorical AND numeric covariates. I need some assistance with this question below.

In a study, the following covariates were collected on a number of subjects.

• z1: Treatment status: 0 if control, 1 if treatment

• z2: Sex: 0 if male, 1 if female

• z3: Age in years

• z4: Height in inches

A Cox proportional hazards model will be constructed to estimate the effect of treatment on the hazard. It is thought that the effect of treatment may be different for men and women. It is further thought that hazard increases with age, but that the effect of treatment does not vary with age. However, the treatment group is slightly older, on the average, than the control group. It is not thought that the hazard function varies with height, but the control group is slightly taller, on average, than the treatment group, and men are somewhat taller, on average, than women.

Express the hazard in terms of the covariates and parameters.

How do you express the hazard in the form below when you have so many different covariates? I know that I need to include the baseline hazard but I'm unsure has to how many beta parameters I need, or what covariates need to be multiplied by those beta parameters.

enter image description here

$\endgroup$
  • $\begingroup$ This sounds like it might be for a homework problem or some type of self study. If so, please read the info for the tag, add that tag to the question, and say more about where you are stuck. For example, could you answer this question if the outcome were a continuous outcome in linear regression and not a Cox regression for survival times as outcomes? $\endgroup$ – EdM Oct 16 at 19:37
  • $\begingroup$ I made the edit. Unfortunately, I'm still very much learning how to do this. I've seen a rather unclear example of how this might be done via linear regression but I wasn't really able to understand it. I know the form of the equation that answers this problem, but that's about it. I'm just not sure what to label my beta parameters or my covariates as. $\endgroup$ – Caladin00 Oct 16 at 21:02
1
$\begingroup$

This question apparently expects you to include all predictors that are reasonably related to hazard into the Cox model.

Remember that the inner product ${\bf z}^T {\bf \beta}$ between predictors and their corresponding coefficients (called the linear predictor) can also be written in the form:

$$ \sum_{i=1}^p \beta_i z_i$$

where $z_i$ is a predictor, $\beta_i$ is its corresponding regression coefficient, and $p$ is the total number of predictors. So there is no problem in including multiple predictors in your model, including interactions among your covariates as predictors, and so on. Just add more predictors on to that sum.*

This isn't really different from the situation in a standard linear regression, except that in a linear regression you usually include the intercept in the linear predictor. The baseline hazard $\lambda_0(t)$ takes the place of an intercept in a Cox regression, which you perhaps can see better by taking the logarithm of your equation for the hazard:

$$\log\lambda_{\bf z}(t) = \log\lambda_0(t) + {\bf z}^T{\bf \beta}.$$

With respect to continuous versus categorical predictors, think about what happens with a continuous predictor when it has a value of 0 versus when it has a value of 1. If a continuous predictor $z_i$ has a value of 0 it will add 0 to the linear predictor. If $z_i$ has a value of 1, it will add $\beta_i$ to the linear predictor.

Is there anything different from this if you instead have a 2-level categorical covariate $z_j$, with one level coded as 0 and the other as 1? At the reference level (coded 0) it adds nothing to the linear predictor, and at the other level (coded 1) it adds $\beta_j$.**

Try putting that information together into your answer. Your decision then is which of your covariates are expected to be associated with hazard and thus should be included in your model. You also should think about whether you might need to add any interactions between covariates as predictors, as you would if the effect of one predictor depends on the value of another predictor. (Note that including an interaction can provide a test of assumptions like "the effect of treatment does not vary with age.")


*In practice you can overfit a model if the ratio of cases to predictors is too small, but that doesn't seem to be an issue here.

**Things get a bit trickier if a categorical covariate has more than 2 levels; then you have to add an additional predictor to the model for each level beyond the second.

$\endgroup$
  • $\begingroup$ Yeah sorry I'm still very confused. I think I understand what you're trying to say but I have no clue how to put this together. I'm still confused how to tie in numerical and categorical covariates. $\endgroup$ – Caladin00 Oct 17 at 5:34
  • $\begingroup$ How does one determine if a categorical covariate is 0 or 1? And what about interactions between the covariates? I know I'm going to be adding quite a few beta parameters but I'm not sure what covariates to mix and match. $\endgroup$ – Caladin00 Oct 17 at 5:38
  • $\begingroup$ @Caladin00 you do need 1 $\beta$ for each covariate. So if you include all of age, sex, treatment, and height (with no interactions) you will need 4 of them. For a categorical covariate it doesn't matter which level gets coded 0 or 1, just affects interpretation of the coefficient and the baseline hazard. In your example, with treatment coded 0 for control and 1 for treated and a coefficient $\beta_t$, treatment adds 0 to the linear predictor for controls and $\beta_t$ for treated. Reversing the coding would just change both the baseline hazard and the meaning of $\beta_t$ accordingly. $\endgroup$ – EdM Oct 17 at 13:51
  • $\begingroup$ @Caladin00 for which covariates to include, just go down the list and ask: is this covariate expected to affect hazard? If so, include it. The statement of the question seems to include that information for each of them. For interactions, ask: is the effect of covariate A on hazard thought to depend on the value of covariate B? If so, include an interaction between them. For example, if "the effect of treatment does not vary with age" then you don't need an interaction between them. $\endgroup$ – EdM Oct 17 at 13:58
  • $\begingroup$ Gotcha! I think I have an understanding of where to go with this now. $\endgroup$ – Caladin00 Oct 17 at 23:29
0
$\begingroup$

So here's what I came up with....

$\lambda_z(t)= \lambda_0(t) \exp(\beta_1z_1 + \beta_{_2}z_{_2} + \beta_{_3}z_{_3} + \beta_{_4}z_{_1}z_{_2} + \beta_{_5}z_{_1}z_{_3} + \beta_{_6}z_{_1}z_{_4} + \beta_{_7}z_{_2}z_{_4})$

I believe that I've accounted for every single condition and interaction between covariates accounted for in the paragraph below.

It is thought that the effect of treatment may be different for men and women. It is further thought that hazard increases with age, but that the effect of treatment does not vary with age. However, the treatment group is slightly older, on the average, than the control group. It is not thought that the hazard function varies with height, but the control group is slightly taller, on average, than the treatment group, and men are somewhat taller, on average, than women.

I'm still unsure as to whether I've listed my interactions correctly but this is a start.

  • Age ($z_{_3}$) was believed to affect the hazard so its included with its own beta parameter and is also used as an interaction on $\beta_{_5}$ with treatment due to the treatment group being older than the control group.

  • Height ($z_{_4}$) was believed to not affect the hazard by itself so I've left it out but I included it in an interaction with treatment($z_{_1}$) and sex ($z_{_2}$) on $\beta_{_6} $ and $\beta_{_7}$ respectively...

$\endgroup$
  • $\begingroup$ @EdM what do you think? $\endgroup$ – Caladin00 Oct 18 at 18:11
  • $\begingroup$ First, if you include a covariate in an interaction you should usually include it by itself. I read the question differently from you. When I read "It is not thought that the hazard function varies with height," I take that to mean it doesn't do so even via interactions with other covariates. If your model includes sex as a covariate and height doesn't matter, do you really care that men are taller than women? And if "the effect of treatment does not vary with age" is there any reason to include the $z_1z_3$ interaction term? $\endgroup$ – EdM Oct 18 at 20:22
  • $\begingroup$ Part of the difficulty here is the difference between a real-life problem and an answer to a question for a course. It's often best practice to include interactions to start, for example to test the claim that "the effect of treatment does not vary with age." But answering a question for a course depends on following the stated assumptions, which in this case only seem to support the one interaction term that you correctly identified in a comment on my answer. Remember that instructors will sometimes include extraneous information to test your understanding of what's really important. $\endgroup$ – EdM Oct 18 at 20:26
  • $\begingroup$ Gotcha. Thanks for your assistance with this. Major help! +1 $\endgroup$ – Caladin00 Oct 18 at 20:26
  • $\begingroup$ To help others who might find this page, please update your own answer with your final version and how your thinking changed as you pursued it further. Also, consider specifying exactly what the baseline hazard $\lambda_0(t)$ represents in the model the way that you finally specify it. For example, unless age values have been otherwise centered, it represents (among other factors) the hazard for a newborn with age=0! That's OK and would give expected predictions for adult ages, but things can get particularly weird that way when there are interactions with continuous covariates. $\endgroup$ – EdM Oct 18 at 20:36

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.