Jointly estimates all treatments and generates Stan code for Bayesian relative mixture cure modeling. It supports various latent and cure model configurations and allows the use of precompiled models or on-the-fly compilation.
Usage
bmcm_stan(
input_data,
formula,
cureformula = ~1,
family_latent = "exponential",
prior_latent = NA,
prior_cure = list(),
centre_coefs = FALSE,
bg_model = c("bg_distn", "bg_fixed"),
bg_varname = "bg_rate",
bg_hr = 1,
t_max = 70,
save_stan_code = FALSE,
read_stan_code = FALSE,
precompiled_model_path = NA,
use_cmdstanr = FALSE,
...
)
Arguments
- input_data
A long-format data frame containing the input data.
- formula
An R formula object specifying the latent model component.
- cureformula
An R formula object specifying the cure fraction model component. Default is
~ 1
.- family_latent
A string or vector specifying the distribution(s) for the latent model component. Supported values are
"exp"
,"weibull"
,"gompertz"
,"lognormal"
,"loglogistic"
, and"gengamma"
.- prior_latent
An optional prior specification for the latent model component. Default is
NA
.- prior_cure
An optional list specifying priors for the cure fraction model component. Default is an empty list.
- centre_coefs
Logical. If
TRUE
, coefficients will be centered. Default isFALSE
.- bg_model
A string specifying the background model type. Supported values are
"bg_distn"
and"bg_fixed"
.- bg_varname
A string specifying the background variable name in
input_data
. Default is"bg_rate"
.- bg_hr
A numeric value for the background hazard ratio adjustment. Default is
1
.- t_max
A numeric value specifying the maximum time horizon for the model. Default is
70
.- save_stan_code
Logical. If
TRUE
, saves the Stan model code to a file. Default isFALSE
.- read_stan_code
Logical. If
TRUE
, reads the Stan model code from a file instead of generating it dynamically. Default isFALSE
.- precompiled_model_path
A string specifying the path to a precompiled model. Default is
NA
.- use_cmdstanr
Logical. If
TRUE
, thecmdstanr
package is used to fit the model. Default isFALSE
.- ...
Additional parameters to pass to the Stan sampler.