# Baseline hazard function is the hazard function obtained when all covariates are set to zero

I am trying to learn Cox proportional hazard model but I have hit a wall with the basehaz function.

Lets suppose for example I have some data that I want to use but there is a column such as BMI. The BMI has 3 levels: Underweight, normal weight and fat. How could one of these levels be set to zero?

In addition lets suppose I have a continuous variable such as IQ. Does that mean the model wants to take the base for the IQ to be 0?

• Would it work to use -1, 0 and 1? Jun 8, 2019 at 11:29
• the baseline hazard can be defined at the mean values (i.e. not strictly zero), but your covariates in the equation for the log-partial-hazards will be centered now (i.e. x - mean(x)). Related: See the "centered" param in rdocumentation.org/packages/survival/versions/2.44-1.1/topics/…. Jun 8, 2019 at 12:44
• Actually, and this is important, the basehaz by default a: returns the cumulative hazard function and b: centers all covariates (regardless of whether they were dummy encoded). The main response is right: if you set centered=F as an option to basehaz, then you will get the BL hazard function for the referent group. It is also related to the survival by $\exp(-\Lambda(t))$ Jun 13, 2019 at 16:17

1) There are different ways to include categorical variables into the analysis. The most popular and default in most packages is so called dummy coding where the first category is the "reference" category and the other are code 1 if the observation is from the category and 0 otherwise. Below is an example with R where "a" is the reference category and the columns x1b and x1c would enter the analysis. The coefficients for these variables would than indicate differences compared to category "a".

# create example data set
df <- data.frame(x1 = sample(letters[1:3], 6, replace = TRUE))
df
#>   x1
#> 1  b
#> 2  c
#> 3  a
#> 4  b
#> 5  a
#> 6  c
# dummy coding
cbind(df, model.matrix(~x1, df)[,-1])
#>   x1 x1b x1c
#> 1  b   1   0
#> 2  c   0   1
#> 3  a   0   0
#> 4  b   1   0
#> 5  a   0   0
#> 6  c   0   1


2) For the baseline hazard continuous variables have to be set to 0 as you suspect, which is why the baseline hazard often does not have a useful interpretation and not the focus of the analysis. What is done sometimes is to center the continuous variable. That way the baseline hazard corresponds to the mean value.

Created on 2019-06-08 by the reprex package (v0.3.0)

• Note that the details can depend on the software package used for the survival analysis. For example, SAS uses the last named level of a categorical variable as the reference, unlike R; see the end of this answer for example. Also if you use the basehaz() function in R at default settings the result is provided for a situation with all predictors at their average values across the dataset. This makes no sense for categorical predictors, as the authors themselves note.
– EdM
Jun 8, 2019 at 12:55