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_cre <- cat_cox(
formula = ~.,
cat_init = cat_init, # Only accept object generated from `cat_cox_initialization`
tau = 1, # Weight for synthetic data
method = "CRE", # Choose from `"CRE"` or `"WME"`
init_coefficients = rep(0, ncol(cat_init$x)), # Initial coefficient values (Only for `CRE`)
tol = 1e-1, # Tolerance for convergence criterion (Only for `CRE`)
max_iter = 3 # Maximum number of iterations for convergence (Only for `CRE`)
)
cat_model_cre
cat_model_wme <- cat_cox(
formula = ~.,
cat_init = cat_init, # Only accept object generated from `cat_cox_initialization`
tau = 1, # Weight for synthetic data
method = "WME"
)
cat_model_wme
Run the code above in your browser using DataLab