cat_cox_bayes: Bayesian Estimation for Catalytic Cox Proportional-Hazards...

View source: R/cat_cox_bayes.R

cat_cox_bayesR Documentation

Bayesian Estimation for Catalytic Cox Proportional-Hazards Model (COX) with Fixed tau

Description

This function performs Bayesian estimation for a catalytic Cox proportional-hazards model (COX) using RStan by given a single tau value. It allows users to estimate the coefficients and cumulative baseline hazard increments over specified time intervals with Bayesian sampling.

Usage

cat_cox_bayes(
  formula,
  cat_init,
  tau = NULL,
  hazard_beta = 2,
  chains = 4,
  iter = 2000,
  warmup = 1000,
  ...
)

Arguments

formula

A formula specifying the Cox model. Should at least include response variables (e.g. ~.).

cat_init

A list generated from cat_cox_initialization.

tau

Optional numeric scalar controlling the weight of the synthetic data in the coefficient estimation, defaults to ncol(cat_init$obs_x).

hazard_beta

Numeric, default 2. Shape parameter for the Gamma distribution in the hazard model.

chains

Integer, default 4. Number of Markov chains to be run in the RStan sampling.

iter

Integer, default 2000. Number of iterations per chain in the RStan sampling.

warmup

Integer, default 1000. Number of warm-up (or burn-in) iterations for each chain.

...

Additional arguments passed to RStan’s rstan::sampling function.

Value

A list containing the values of all the arguments and the following components:

stan_data

A data list used for fitting RStan sampling model.

stan_model

Compiled RStan model object for Cox regression.

stan_sample_model

Fitted RStan sampling model containing posterior samples.

coefficients

Mean posterior estimates of model coefficients from stan_sample_model.

increment_cumulative_baseline_hazard

Mean posterior estimates of Estimated cumulative hazard increments over time intervals from stan_sample_model.

Examples


library(survival)
data("cancer")
cancer$status[cancer$status == 1] <- 0
cancer$status[cancer$status == 2] <- 1

cat_init <- cat_cox_initialization(
  formula = Surv(time, status) ~ 1, # formula for simple model
  data = cancer,
  syn_size = 100, # Synthetic data size
  hazard_constant = 0.1, # Hazard rate value
  entry_points = rep(0, nrow(cancer)), # Entry points of each observation
  x_degree = rep(1, ncol(cancer) - 2), # Degrees for polynomial expansion of predictors
  resample_only = FALSE, # Whether to perform resampling only
  na_replace = stats::na.omit # How to handle NA values in data
)

cat_model <- cat_cox_bayes(
  formula = ~., # Should at least include response variables
  cat_init = cat_init, # Only accept object generated from `cat_cox_initialization`
  tau = 1, # Weight for synthetic data
  hazard_beta = 2, # Shape parameter for the Gamma distribution in the hazard model
  chains = 1, # Number of Markov chains to be run in the RStan sampling
  iter = 10, # Number of iterations per chain in the RStan sampling
  warmup = 5 # Number of warm-up (or burn-in) iterations for each chain
)
cat_model


catalytic documentation built on April 4, 2025, 5:51 a.m.