brm_surv {rmstBayespara} | R Documentation |
Bayesian regression models using 'Stan' for survival time
Description
A function of Bayesian regression models using stan for parametric survival time. Exponential, Weibull, log-normal, and log-logistic model with fixed-effect, random-effect and frailty-effect can be available.
Usage
brm_surv(
time,
cnsr,
var,
rvar,
family = "exponential",
random = "fixed",
data,
iter = 2000,
warmup = 1000,
seed = NA,
chains = 4
)
Arguments
time |
name of time variable in data. Need to set character. |
cnsr |
name of censor variable in data. Need to set character. |
var |
vector of covariate names in data. Need to set character. |
rvar |
name of random effect in data. Need to set character. |
family |
A description of the response distribution and link function to be used in the model. 'exponential', 'Weibull', 'log-normal', and 'log-logistic' can be selected. |
random |
A description of random effect. 'fixed', 'normal', and 'frailty' are available. |
data |
An object of class data.frame (or one that can be coerced to that class) containing data of all variables used in the model. |
iter |
Number of total iterations per chain (including warmup; defaults to 2000). |
warmup |
A positive integer specifying number of warmup (aka burnin) iterations. This also specifies the number of iterations used for stepsize adaptation, so warmup draws should not be used for inference. The number of warmup should not be larger than iter and the default is iter/2. |
seed |
The seed for random number generation to make results reproducible. If NA (the default), Stan will set the seed randomly. |
chains |
Number of Markov chains (defaults to 4). |
Value
A list of an object of class brmsfit or stanfit (see rstan and brms), sampling values from posterior distribution, leave-one-out cross-validation, and widely applicable information criterions.
Examples
d <- data.frame(time=1:100,
status=sample(0:1, size=100, replace=TRUE),
arm=sample(c("t", "c"), size=100, replace=TRUE),
sex=sample(1:2, size=100, replace=TRUE),
district=sample(1:5, size=100, replace=TRUE)
)
head(d)
fit_x_r <- brm_surv(time="time", cnsr="1-status",
var=c("factor(arm)", "factor(sex)"),
rvar="district", data=d,
family="Weibull", random="frailty"
)
fit_x_r$fit
fit_x_r$post_sample
fit_x_r$waic
fit_x_r$loo