predict.BayesSurvive: Predict survival risk

View source: R/predict.BayesSurvive.R

predict.BayesSurviveR Documentation

Predict survival risk

Description

Predict survival probability, (cumulative) hazard or (integrated) Brier scores based on Cox regression models

Usage

## S3 method for class 'BayesSurvive'
predict(
  object,
  survObj.new,
  type = "brier",
  method = "mean",
  times = NULL,
  subgroup = 1,
  verbose = TRUE,
  ...
)

Arguments

object

fitted object obtained with BayesSurvive

survObj.new

a list containing observed data from new subjects with components t, di, x. If type is among c("hazard", "cumhazard", "survival"), only survObj.new$X is needed.

type

option to chose for predicting brier scores with type="brier" or one of type=c("brier", "hazard", "cumhazard", "survival"))

method

option to use the posterior mean ("mean") of coefficients for prediction or Bayesian model averaging ("BMA") for prediction

times

time points at which to evaluate the risks. If NULL (default), the event/censoring times are used. If type="brier", the largest one of the times is used

subgroup

index of the subgroup in survObj.new for prediction. Default value is 1

verbose

logical value to print IBS of the NULL model and the Bayesian Cox model

...

not used

Value

A list object with 5 components if type="brier" including "model", "times", "Brier", "IBS" and "IPA" (Index of Prediction Accuracy), otherwise a list of 7 components with the first component as the specified argument type and "se", "band", "type", "diag", "baseline" and "times", see function riskRegression::predictCox for details

Examples


library("BayesSurvive")
set.seed(123)

# Load the example dataset
data("simData", package = "BayesSurvive")

dataset <- list(
  "X" = simData[[1]]$X,
  "t" = simData[[1]]$time,
  "di" = simData[[1]]$status
)

# Initial value: null model without covariates
initial <- list("gamma.ini" = rep(0, ncol(dataset$X)))
# Hyperparameters
hyperparPooled <- list(
  "c0"     = 2, # prior of baseline hazard
  "tau"    = 0.0375, # sd for coefficient prior
  "cb"     = 20, # sd for coefficient prior
  "pi.ga"  = 0.02, # prior variable selection probability for standard Cox models
  "a"      = -4, # hyperparameter in MRF prior
  "b"      = 0.1, # hyperparameter in MRF prior
  "G"      = simData$G # hyperparameter in MRF prior
)


# run Bayesian Cox with graph-structured priors
fit <- BayesSurvive(
  survObj = dataset, hyperpar = hyperparPooled,
  initial = initial, nIter = 50
)
# predict survival probabilities of the train data
predict(fit, survObj.new = dataset)



BayesSurvive documentation built on April 3, 2025, 5:58 p.m.