Skip to contents

predict() gives, for each row of newdata (or of the data the model was fit to), the cumulative hazard \(H(t \mid x) = B_0(t) + \sum_j B_j(t) x_j\) or the survival \(\exp(-H(t \mid x))\). An additive model can give a cumulative hazard that falls below 0 for some covariate values, so it's floored at 0.

Usage

# S3 method for class 'aalen_additive'
predict(
  object,
  newdata,
  type = c("survival", "cumhaz"),
  times,
  conf_level = object$conf_level,
  ...
)

Arguments

object

An aalen_additive() fit.

newdata

A data frame with the covariates of the subjects to predict for. The default is the data the model was fit to.

type

What to predict: "survival" (the default) or "cumhaz".

times

The times to read the curves at. The default is the distinct event times used in the fit.

conf_level

The confidence level. The default is the level the model was fit with.

...

Unused.

Value

A data frame with one row per subject and time: subject (the row of newdata), time, estimate, std_error (of the cumulative hazard), conf_low, and conf_high.

Details

The standard error of the cumulative hazard is \(\sqrt{x^\top \Sigma(t) x}\), where \(\Sigma(t)\) sums the outer products of the increments up to \(t\). Its limits are \(H \pm z\) standard errors, floored at 0, and the survival limits follow from them.

Examples

lung <- data.frame(
  time = c(306, 455, 1010, 210, 883, 1022, 310, 361, 218, 166, 170, 654, 728, 71, 567, 144,
    613, 707, 61, 88),
  status = c(2, 2, 1, 2, 2, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2),
  age = c(74, 68, 56, 57, 60, 74, 68, 71, 53, 61, 57, 68, 68, 60, 57, 67, 70, 63, 56, 57),
  sex = c(1, 1, 1, 1, 1, 1, 2, 2, 1, 1, 1, 2, 2, 1, 1, 1, 1, 1, 1, 1)
)
fit <- aalen_additive(Surv(time, status) ~ age + sex, data = lung)
newdata <- data.frame(age = c(55, 70), sex = c(1, 2))
predict(fit, newdata = newdata, type = "cumhaz", times = c(100, 200, 300))
#>   subject time  estimate  std_error   conf_low   conf_high
#> 1       1  100 0.3482778 0.20340020 0.00000000 0.746934909
#> 2       1  200 0.6382407 0.28171851 0.08608262 1.190398868
#> 3       1  300 1.1313140 0.45482415 0.23987501 2.022752932
#> 4       2  100 0.0000000 0.01572860 0.00000000 0.005079577
#> 5       2  200 0.0000000 0.02177698 0.00000000 0.010292197
#> 6       2  300 0.0000000 0.03720736 0.00000000 0.000000000