Skip to contents

predict() gives, for each row of newdata (or of the data the model was fit to), the linear predictor, quantiles of the survival time, the survival or cumulative hazard curve, the mean survival time, or the restricted mean survival time.

Usage

# S3 method for class 'aft'
predict(
  object,
  newdata,
  type = c("lp", "quantile", "survival", "cumhaz", "mean", "expectation"),
  p = 0.5,
  times,
  tau,
  conf_level = object$conf_level,
  ...
)

Arguments

object

An aft() 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: "lp" (the default), "quantile", "survival", "cumhaz", "mean", or "expectation" (the restricted mean).

p

For "quantile", the proportions of subjects who have had the event, between 0 and 1. The default, 0.5, gives the median.

times

For "survival" and "cumhaz", the times to read the curves at.

tau

For "expectation", the end of the window for the restricted mean.

conf_level

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

...

Unused.

Value

For "lp", a numeric vector with one value per row of newdata. Otherwise a data frame with one row per subject (and per proportion or time): subject (the row of newdata), then p for "quantile", time for "survival" and "cumhaz", or tau for "expectation", then estimate, std_error, conf_low, and conf_high.

Details

The linear predictor is \(\eta = x^\top \beta\), the location of \(\log T\). With the standard error distribution's survival function \(S_0\) and quantile function \(w_p\), survival is \(S(t) = S_0((\log(t - \gamma) - \eta) / \sigma)\) and the \(p\) quantile is \(\gamma + \exp(\eta + \sigma w_p)\), with \(\gamma = 0\) unless the model has a threshold. The mean is \(\gamma + \int_0^\infty S(t) dt\), and the restricted mean is the same integral up to tau.

Standard errors use the delta method with the full variance of the parameters (the coefficients, the log scale, the generalized gamma's \(Q\), and the threshold). Confidence limits for quantiles, means, and restricted means are built on the log scale. Limits for survival and the cumulative hazard are built on the scale of \(z = (\log(t - \gamma) - \eta) / \sigma\), which for the Weibull is the log of the cumulative hazard, so they stay within 0 and 1. For the generalized gamma, a change in \(Q\) is carried onto that scale as the change in \(z\) that moves survival as much at the estimated \(Q\).

Examples

lung <- data.frame(
  time = c(306, 455, 1010, 210, 883, 1022, 310, 361, 218, 166, 170, 654, 728, 71, 567),
  status = c(2, 2, 1, 2, 2, 1, 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),
  sex = c(1, 1, 1, 1, 1, 1, 2, 2, 1, 1, 1, 2, 2, 1, 1)
)
fit <- aft(Surv(time, status) ~ age + sex, data = lung)
newdata <- data.frame(age = c(55, 70), sex = c(1, 2))

predict(fit, newdata = newdata, type = "quantile", p = c(0.25, 0.5, 0.75))
#>   subject    p estimate std_error  conf_low conf_high
#> 1       1 0.25 197.9094  82.28969  87.60751  447.0865
#> 2       1 0.50 370.8781 126.44349 190.12141  723.4881
#> 3       1 0.75 608.4557 192.38162 327.41300 1130.7380
#> 4       2 0.25 226.0589  94.97576  99.22018  515.0425
#> 5       2 0.50 423.6296 156.15261 205.69695  872.4583
#> 6       2 0.75 694.9988 252.72031 340.77221 1417.4374
predict(fit, newdata = newdata, type = "survival", times = c(200, 400))
#>   subject time  estimate std_error  conf_low conf_high
#> 1       1  200 0.7468089 0.1264603 0.4025461 0.9105854
#> 2       1  400 0.4627667 0.1671827 0.1449395 0.7353580
#> 3       2  200 0.7847843 0.1158108 0.4496084 0.9291624
#> 4       2  400 0.5274907 0.1754354 0.1699512 0.7938601
predict(fit, newdata = newdata, type = "expectation", tau = 730)
#>   subject tau estimate std_error conf_low conf_high
#> 1       1 730 395.4743  91.89064 250.8054  623.5907
#> 2       2 730 431.4171  98.51606 275.7539  674.9524