Cox Model Prediction

Share:

Description

This function takes a fitted Cox model, i.e., a model estimated by cox.mode or cox.mcmc and computes predictions given a new data set or the original values. Survival probabilities are computed using numerical integration, therefore, computation may take some time. To avoid problems with computer memory, the prediction of survival probabilities can be split into chunks and computed parallel on different cores.

Usage

1
2
3
4
5
cox.predict(object, newdata,
  type = c("link", "parameter", "probabilities"),
  FUN = function(x) { mean(x, na.rm = TRUE) },
  time = NULL, subdivisions = 100, cores = NULL,
  chunks = 1, verbose = FALSE, ...)

Arguments

object

A "bamlss" object as returned from function bamlss using the optimizer cox.mode or sampler function cox.mcmc.

newdata

A data frame or list containing the values of the model covariates at which predictions are required. If missing newdata is the model.frame of the provided model.

type

Specifies the type of predictions that should be computed.

FUN

A function that should be applied on each row of the samples of the additive predictor, parameter or probabilities. Per default the function computes means of samples, however, other functions like quantile can be supplied.

time

numeric, specifies the time for which survival probabilities should be computed if type = "probabilities". Note that this overwrites survival times that are supplied in argument newdata.

subdivisions

How many time points should be created for each individual.

cores

Specifies the number of cores that should be used for prediction. The problem is split into core chunks, each chunk is then processed by one core.

chunks

The number of chunks that should be processed sequentially on one core. This way memory problems can be avoided when computing survival times for large problems.

verbose

Print progress information.

...

Arguments passed to predict.bamlss.

Value

Depending on the type of function provided in argument FUN, a numeric vector or matrix.

See Also

cox.mcmc, cox_bamlss, surv.transform, simSurv, bamlss, predict.bamlss

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
## Not run: library("survival")
set.seed(123)

## Simulate survival data.
d <- simSurv(n = 500)

## Formula of the survival model, note
## that the baseline is given in the first formula by s(time).
f <- list(
  Surv(time, event) ~ s(time) + s(time, by = x3),
  gamma ~ s(x1) + s(x2)
)

## Cox model with continuous time.
## Note the the family object cox_bamlss() sets
## the default optimizer and sampler function!
## First, posterior mode estimates are computed
## using function cox.mode(), afterwards the
## sampler cox.mcmc() is started.
b <- bamlss(f, family = "cox", data = d)

## Predict survival probabilities P(T > t).
p <- predict(b, type = "probabilities",
  time = 3, subdivisions = 100, FUN = quantile)

## End(Not run)

Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker.