# Modelling proportional hazards in Cox Model using coxph in R

Assume I have a heterogeneous sample with two categorical variables A and B, each with 2 levels. Now I want to measure the effect of these on the survival function.

So we assume proportional hazard, i.e. the survival function can be written as $S_0^{exp(\beta^T z)}$ for the covariates (categorical variables A, and B) and the corresponding coefficients $\beta$.

I solve this in coxph in R.

Most often, you would for these variables and levels, assume the model

$\beta_0 + \beta_A z_A + \beta_B z_B$, where $z_A=1$ if it belongs to the first level, and 0 if not. The variable $z_B$ is defined analogously.

Since the intercept may be "merged" with the baseline survival function $S_0$, this is not included in the model. So the model argument for the coxph function in R would be just $z_A$ and $z_B$. But then I can only measure the relative effect of $z_B$ vs $z_A$, isn't there anyway to obtain the intercept as well?

Instead, I tried to use the model $z_{A=0}$, $z_{A=1}$,$z_{B=0}$ and $z_{B=1}$. But this returns the error that the covariates matrix is singular. Which I don't clearly understand. I thought the model would be singular if, for instance, the intercept would be included as well (but now as I'm writing this, perhaps the intercept is indeed included as I mentioned), because then we could decrease $\beta_0$ and increase all other variables by the same amount and obtain the same prediction, so there's no unique solution for the system of equations.

• I'm a bit confused because you seem to understand why the intercept isn't estimable (i.e. any estimate would fit the data as well as any other) - what would you do with it? Are you asking how to estimate the baseline survival function $S_0$? Apr 20 '15 at 14:41
• Ok, my point was that, assuming I would like to perform a simulation study. So I choose a baseline survival function $S_0$ and for each simulated observation $i$, I choose some set of covariates with predetermined coefficients, then I'd like to see potential biases in the estimation of the parameters. Assuming the same setting as described above, i.e. modeled by an intercept and 1 dummy each for A and B. Then I couldn't estimate all coefficients Apr 21 '15 at 7:29
• So are you asking how to estimate the intercept that's been applied to a known baseline survival function? (If so please edit the question to reflect this.) Apr 21 '15 at 8:59

To help illustrate this, consider if you had a subject with all 0 covariates. By definition, their survival distribution will be defined by the baseline survival function, i.e. $S_o(t)$. But if we included an intercept in our model, the survival probability at time $t$ would be equal to
$S_o(t)^{exp( \beta_0)}$
Clearly, this only makes sense if $\beta_0 = 0$.