First thank you for taking time to help me! I appreciate it. I wouldn't be here unless I didn't feel like I was already spinning my wheels.

I'm trying to learn more about survival analysis and coxph. Obviously, theres a bit I don't understand. I'm trying to understand how I can practically interpret the outputs from a model.

I'm using python, not R so I can't use what's mentioned below. Can someone explain to me like I'm 5 what this stuff means? I've read a bunch of the formulas and theory but I can't find easy explanations for the output of the model.

When I read "R" documentation from the survival package I see this when I look at the PREDICT function

Choices are the linear predictor ("lp"), the risk score exp(lp) ("risk"), the expected number of events given the covariates and follow-up time ("expected"), and the terms of the linear predictor ("terms"). The survival probability for a subject is equal to exp(-expected).

Question 1:


  • linear predictor ("lp")
  • risk
  • expected
  • terms

Question 2

  • I'm using a package (h2o, python) that only outputs linear predictor ("lp"). How do I convert "lp" to "expected" so that I can then do exp(-expected) because ultimately I just want the probability that a machine is still working in 2022, 2023, 2024 (I want probability)

Again thank you so much for your understanding and taking the time to help me out here. I'm having a hard time connecting theory to practicability in my scenario.


1 Answer 1


A Cox model estimates the hazard, i.e. instantaneous rate of occurrence of events, at time $t$ given a set of predictors, $x$. Denote this as $h(t|X=x)$. There are two parts to the model: the so-called "baseline hazard", $h_0(t)$, which is interpreted as the hazard function over $t$ for an observation with covariate pattern $X=0$, and the hazard ratio, $\exp(x^\top\beta)$, which is the relative change in the hazard comparing an observation with $X=x$ to an observation with $X=0$. Thus, for any arbitrary covariate pattern $X=x$, the hazard at time $t$ is modeled by $h(t|X=x) = h_0(t)\exp(x^\top\beta)$. When fitting this model, there are two quantities estimated: $h_0(t)$ (the baseline hazard) and $\beta$ (the log-hazard ratio); these estimates are denoted by $\hat h_0(t)$ and $\hat\beta$.

With this notation, here are my answers to your Question(s) 1:

  • The linear predictor ("lp") quantity is $x^\top\beta$ and estimated by $x^\top\hat\beta$. It is not a function of time and does not require an estimate of the baseline hazard.

  • The risk quantity is $\exp(x^\top\beta)$ and estimted by $\exp(x^\top\hat\beta)$ (an aside: this is not an estimate of absolute risk; I would personally call this the estimated relative risk). It is not a function of time and does not require an estimate of the baseline hazard.

  • The expected quantity is $\int_0^{t} h_0(u) \exp(x^\top\beta)du$. It is also called the cumulative hazard. It is generally meaningful when an observation can have multiple events as it gives you an estimate of how many failure times you would expect over the observation's actual follow-up time and their covariate pattern $X=x$. It is a function of time (each observation's total follow-up time is plugged in) and does require an estimate of the baseline hazard.

  • The terms quantity is (I believe) a vector of values for each observation as long as the number of covariates that you have. If $x^\top\beta \equiv \sum_{j=1}^p x_j\beta_j$, then terms would be the set $\{x_j\beta_j\}_{j=1}^p$.

I find the vignette for the R package survival to be helpful, even if you don't end up using the R functions themselves.

To your Question 2: I understand you to be interested in the survival probability $\Pr(T > t|x)$, which as you note can be expressed as $\Pr(T>t|x) = \exp\left (-\int_0^{t} h_0(u) \exp(x^\top\beta)du\right)$. Thus you must have an estimate of both the baseline hazard function $h_0(t)$ and the log-hazard ratios $\beta$. I don't know how to do this in the Python, but I found this page which I presume you are familiar with. I ran the example code they provide at the very bottom of the page and then I compared with the coxph function in the R package survival, which I am familiar with. The upshot is: in coxph, you would change type = "survival" to get the survival probabilities (below), but if I try that in h2o.predict, it seems to ignore the argument. So I don't know how to get the survival probabilities in h2o but see below for getting them in the coxph.

# First run the code from the h2o page I link to
# I copied this from the page I linked to. It gives the linear predictors (lp). 
h2o.predict(heart_coxph, newdata = test)
# here is code using the coxph function that gives the same linear predictors 
predict(coxph(Surv(I(stop-start), event) ~ age, data = as.data.frame(train)), newdata = as.data.frame(test), type = "lp" )

# In coxph, I would change type = "survival" to get the survival probabilities:
predict(coxph(Surv(I(stop-start), event) ~ age, data = as.data.frame(train)), newdata = as.data.frame(test), type = "survival" )
# but if I try to change type = "survival" in the h2o package, it ignores it.
# adding type = "survival" doesn't change anything:
h2o.predict(heart_coxph, newdata = test, type = "survival")

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.