Bayesian survival model - with stratification and shrinkage - using Weibull regression on both scale and shape parameters, resulting in time-dependent (i.e. dynamic) hazard ratios.
bsgw(formula, data, formulas=formula, weights, subset, na.action=na.fail, init="survreg"
, ordweib=FALSE, scale=0, control=bsgw.control(), print.level=2)
bsgw.control(scalex=TRUE, iter=1000, burnin=round(iter/2), sd.thresh=1e-4
, lambda=0.0, lambdas=lambda, nskip=round(iter/10), alpha.min=0.1, alpha.max=10.0
, beta.max=log(20), betas.max=5.0, memlim.gb=8)
# S3 method for bsgw
print(x, ...)
The function bsgw.control
returns a list with elements identical to the input parameters. The function bsgw
returns an object of class bsgw
, with the following components:
The matched call.
Same as input.
Same as input.
Same as input. *Not supported yet*
Same as input. *Not supported yet*
Same as input. *Not supported yet* (current behavior is na.fail
)
Initial values for scale and shape coefficients used in MCMC sampling, either by performing an ordinary Weibull regression or by extracting estimated coefficients from a previously-performed such regression.
Same as input.
Value of scale parameter, estimated using ordinary Weibull regression by calling the survreg
function in the survival
package.
The "survreg"
object returned from calling the same function for initialization of coefficients.
Same as input.
Same as input.
Model matrix used for regression on scale parameter, after potential centering and scaling. The corresponding vector of coefficients is called beta
.
Model matrix used for regression on shape parameter, after potential centering and scaling. The corresponding vector of coefficients is called betas
.
Survival response variable (time and status) used in the model.
The contrasts used for scale-parameter coefficients.
The contrasts used for shape-parameter coefficients.
A record of the levels of the factors used in fitting for scale parameter regression.
A record of the levels of the factors used in fitting for shape parameter regression.
The terms object used for scale parameter regression.
The terms object used for shape parameter regression.
Names of columns for X
, also names of scale coefficients.
Names of columns for Xs
, also names of shape coefficients.
Index of columns of X
where scaling has been applied.
Index of columns of Xs
where scaling has been applied.
Vector of centering parameters for columns of X
indicated by apply.scale.X
.
Vector of scaling parameters for columns of X
indicated by apply.scale.X
.
Vector of centering parameters for columns of Xs
indicated by apply.scale.Xs
.
Vector of scaling parameters for columns of Xs
indicated by apply.scale.Xs
.
Vector of indexes into X
for which sampling occured. All columns of X
whose standard deviation falls below sd.thresh
are excluded from sampling and their corresponding coefficients are clamped to 0
.
Vector of indexes into Xs
for which sampling occured. All columns of Xs
whose standard deviation falls below sd.thresh
are excluded from sampling and their corresponding coefficients are clamped to 0
.
List of median values, with elements including beta
(coefficients of scale regression), betas
(coefficients of shape regression), survreg.scale
(value of surgreg
-style scale parameter for all training set observations).
List of coefficient samples, with the following elements: 1) beta
(scale parameter coefficients), 2) betas
(shape parameter coefficients), 3) lp
(vector of linear predictor for scale parameter, within-sample), 4) loglike
(log-likelihood of model), 5) logpost
(log-posterior of mode, i.e. log-likelihood plus the shrinkage term). The last two entities are used during within-sample prediction of response, i.e. during a subsequent call to predict
. Each parameter has control$iter
samples.
Kaplan-Meyer fit to training data. Used in plot.bsgw method.
Maximum time value in training set. Used in predict.bsgw for automatic selection of the tvec
parameter.
Survival formula expressing the time/status variables as well as covariates used in regression on scale parameter. Currently, only right and left censoring is supported. Must include intercept term.
Data frame containing the covariates and response variable.
Formula expressing the covariates used in regression on shape parameter. No left-hand side is necessary since the response variable information is extracted from formula
. Default value is formula
. Must include intercept term.
Optional vector of case weights. *Not supported yet*
Subset of the observations to be used in the fit. *Not supported yet*
Missing-data filter function. *Not supported yet (only na.fail behavior works)*
Initialization behavior. Currently, three options are supported: 1) If init="survreg"
, an ordinary Weibull regression is performed and coefficients are used to initialize the bsgw MCMC run. 2) If init
is a survreg
object, e.g. from a previous Weibull regression fit, the object can be directly passed as parameter. 3) If init
is any other value, or if survreg
produces error or warning, we simply set all coefficients to zero.
If TRUE
, a Bayesian ordinary Weibull model is estimated, in which any covariates in formulas
are stripped away, and the inverse-logit transformation in the shape-parameter regression is replaced with a simple exponential transformation. If shrinkage parameters are kept at 0, the result is a Bayesian equivalent of an ordinary Weibull regression.
If scale>0
, the value of the shape parameter is fixed, i.e. not estimated from data.
See bsgw.control
for a description of the parameters inside the control
list.
Controlling verbosity level.
If TRUE
, each covariate vector is centered and scaled before model estimation. The scaling parameters are saved in return object, and used in subsequent calls to predict
function. Users are strongly advised against turning this feature off, since the quality of Gibbs sampling MCMC is greatly enhanced by covariate centering and scaling.
Number of MCMC samples to draw.
Number of initial MCMC samples to discard before calculating summary statistics.
Threshold for standard deviation of a covariate (after possible centering/scaling). If below the threshold, the corresponding coefficient is removed from sampling, i.e. its value is clamped to zero.
Bayesian Lasso shrinkage parameter for scale-parameter coefficients.
Bayesian Lasso shrinkage parameter for shape-parameter coefficients.
Controlling how often to print progress report during MCMC run. For example, if nskip=10
, progress will be reported after 10,20,30,... samples.
Lower bound on the shape parameter.
Upper bound on the shape parameter.
Upper bound on absolute value of coefficients of scale parameter (with the exception of the intercept).
Upper bound on absolute value of coefficients of shape parameter (with the exception of the intercept).
User-specified limit on total memory (in GB) available during prediction. Hazard, cumulative hazard, and survival prediction objects are all three-dimensional arrays which can quickly grow very large, depending on data length, number of MCMC samples collected, and number of time points along which prediction is made.
Object of class 'bsgw', usually the result of a call to the bsgw
.
Arguments to be passed to/from other methods.
Alireza S. Mahani, Mansour T.A. Sharabiani
Mazucheli J., Louzada-Neto F. and Achnar J.A. (2002). Lifetime models with nonconstant shape parameters. Confiabilidade. III Jornada Regional de Estatistica e II Semana da Estatistica, Maringa.
Neal R.M. (2003). Slice Sampling. Annals of Statistics, 31, 705-767.
Park T. and Casella G. (2008). The Bayesian Lasso. Journal of the American Statistical Association, 103, 681-686.
For calculating median and lower/upper bounds on coefficients, use summary.bsgw.
For prediction, use predict.bsgw.
## model estimation using 800 samples, printing progress every 100 samples
library("survival")
data(ovarian)
est <- bsgw(Surv(futime, fustat) ~ ecog.ps + rx, ovarian
, control=bsgw.control(iter=400, nskip=100))
## comparing shape of Weibull curves between ordinary Weibull and bsgw
## since in bsgw shape is dependent on covariates, only a population average is meaningful
## Note that survreg-style scale is inverse of bsgw shape parameter, see survreg help page
west <- survreg(Surv(futime, fustat) ~ ecog.ps + rx, ovarian)
cat("constant survreg-style scale parameter:", west$scale, "\n")
cat("population average of survreg-style scale parameter from bsgw model:"
, mean(est$median$survreg.scale), "\n")
Run the code above in your browser using DataLab