Learn R Programming

BayesSurvive (version 0.1.0)

coef.BayesSurvive: Create a dataframe of estimated coefficients

Description

Estimate regression coefficients with posterior mean/median, credible intervals, standard deviation, or MPM estimates, posterior gammas

Usage

# S3 method for BayesSurvive
coef(
  object,
  MPM = FALSE,
  type = "mean",
  CI = 95,
  SD = FALSE,
  subgroup = 1,
  ...
)

Value

dataframe object

Arguments

object

an object of class BayesSurvive

MPM

logical value to obtain MPM coefficients. Default: FALSE

type

type of point estimates of regression coefficients. One of c("mean", "median"). Default is mean

CI

size (level, as a percentage) of the credible interval to report. Default: 95, i.e. a 95% credible interval

SD

logical value to show each coefficient's standard deviation over MCMC iterations

subgroup

index of the subgroup for visualizing posterior coefficients

...

other arguments

Examples

Run this code

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
)

# \donttest{
# run Bayesian Cox with graph-structured priors
fit <- BayesSurvive(
  survObj = dataset, hyperpar = hyperparPooled,
  initial = initial, nIter = 50
)

# show posterior coefficients
betas <- coef(fit)
head(betas)
# }

Run the code above in your browser using DataLab