BayesSurvive {BayesSurvive} | R Documentation |
Fit Bayesian Cox Models
Description
This is the main function to fit a Bayesian Cox model with graph-structured selection priors for sparse identification of high-dimensional covariates.
Usage
BayesSurvive(
survObj,
model.type = "Pooled",
MRF2b = FALSE,
MRF.G = TRUE,
g.ini = 0,
hyperpar = NULL,
initial = NULL,
nIter = 1,
burnin = 0,
thin = 1,
output_graph_para = FALSE,
verbose = TRUE
)
Arguments
survObj |
a list containing observed data from |
model.type |
a method option from
|
MRF2b |
logical value. |
MRF.G |
logical value. |
g.ini |
initial values for latent edge inclusion indicators in graph, should be a value in [0,1]. 0 or 1: set all random edges to 0 or 1; value in (0,1): rate of indicators randomly set to 1, the remaining indicators are 0 |
hyperpar |
a list containing prior parameter values |
initial |
a list containing prior parameters' initial values |
nIter |
the number of iterations of the chain |
burnin |
number of iterations to discard at the start of the chain. Default is 0 |
thin |
thinning MCMC intermediate results to be stored |
output_graph_para |
allow ( |
verbose |
logical value to display the progess of MCMC |
Value
An object of class BayesSurvive
is saved as
obj_BayesSurvive.rda
in the output file, including the following components:
input - a list of all input parameters by the user
output - a list of the all output estimates:
"
gamma.p
" - a matrix with MCMC intermediate estimates of the indicator variables of regression coefficients."
beta.p
" - a matrix with MCMC intermediate estimates of the regression coefficients."
h.p
" - a matrix with MCMC intermediate estimates of the increments in the cumulative baseline hazard in each interval.
call - the matched call.
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 (spike) for coefficient prior
"cb" = 20, # sd (spike) 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 = 100
)
# show posterior mean of coefficients and 95% credible intervals
library("GGally")
plot(fit) +
coord_flip() +
theme(axis.text.x = element_text(angle = 90, size = 7))