## Stata 15 help for bayes_streg

```
[BAYES] bayes: streg -- Bayesian parametric survival models

Syntax

bayes [, bayesopts] : streg [varlist] [if] [in] [, options]

options                         Description
-------------------------------------------------------------------------
Model
noconstant                    suppress constant term
distribution(exponential)     exponential survival distribution
distribution(gompertz)        Gompertz survival distribution
distribution(loglogistic)     loglogistic survival distribution
distribution(llogistic)       synonym for distribution(loglogistic)
distribution(weibull)         Weibull survival distribution
distribution(lognormal)       lognormal survival distribution
distribution(lnormal)         synonym for distribution(lognormal)
distribution(ggamma)          generalized gamma survival distribution
frailty(gamma)                gamma frailty distribution
frailty(invgaussian)          inverse-Gaussian distribution
time                          use accelerated failure-time metric

Model 2
strata(varname)               strata ID variable
offset(varname)               include varname in model with coefficient
constrained to 1
shared(varname)               shared frailty ID variable
ancillary(varlist)            use varlist to model the first ancillary
parameter
anc2(varlist)                 use varlist to model the second ancillary
parameter
collinear                     keep collinear variables

Reporting
nohr                          do not report hazard ratios
tratio                        report time ratios
noshow                        do not show st setting information
display_options               control spacing, line width, and base and
empty cells

level(#)                      set credible level; default is level(95)
-------------------------------------------------------------------------
You must stset your data before using bayes: streg; see [ST] stset.
varlist may contain factor variables; see fvvarlist.
bayes: streg, level() is equivalent to bayes, clevel(): streg.
For a detailed description of options, see Options in [ST] streg.

bayesopts                       Description
-------------------------------------------------------------------------
Priors
* normalprior(#)                specify standard deviation of default
normal priors for regression
coefficients and log-ancillary
parameters; default is normalprior(100)

prior(priorspec)              prior for model parameters; this option
may be repeated
dryrun                        show model summary without estimation

Simulation
mcmcsize(#)                   MCMC sample size; default is
mcmcsize(10000)
burnin(#)                     burn-in period; default is burnin(2500)
thinning(#)                   thinning interval; default is thinning(1)
rseed(#)                      random-number seed
exclude(paramref)             specify model parameters to be excluded
from the simulation results

Blocking
* blocksize(#)                  maximum block size; default is
blocksize(50)
block(paramref[, blockopts])  specify a block of model parameters; this
option may be repeated
blocksummary                  display block summary

* noblocking                    do not block parameters by default

Initialization
initial(initspec)             initial values for model parameters
nomleinitial                  suppress the use of maximum likelihood
estimates as starting values
initrandom                    specify random initial values
initsummary                   display initial values used for
simulation

* noisily                       display output from the estimation
command during initialization

scale(#)                      initial multiplier for scale factor;
default is scale(2.38)
covariance(cov)               initial proposal covariance; default is
the identity matrix

Reporting
clevel(#)                     set credible interval level; default is
clevel(95)
hpd                           display HPD credible intervals instead of
the default equal-tailed credible
intervals
* nohr                          do not report hazard ratios
* tratio                        report time ratios; requires option time
with streg
eform[(string)]               report exponentiated coefficients and,
optionally, label as string
batch(#)                      specify length of block for batch-means
calculations; default is batch(0)
saving(filename[, replace])   save simulation results to filename.dta
nomodelsummary                suppress model summary
dots                          display dots every 100 iterations and
iteration numbers every 1,000
iterations
dots(#[, every(#)])           display dots as simulation is performed
[no]show(paramref)            specify model parameters to be excluded
from or included in the output
notable                       suppress estimation table
title(string)                 display string as title above the table
of parameter estimates
display_options               control spacing, line width, and base and
empty cells

search(search_options)        control the search for feasible initial
values
corrlag(#)                    specify maximum autocorrelation lag;
default varies
corrtol(#)                    specify autocorrelation tolerance;
default is corrtol(0.01)
-------------------------------------------------------------------------
* Starred options are specific to the bayes prefix; other options are
common between bayes and bayesmh.
Options prior() and block() can be repeated.
priorspec and paramref are defined in [BAYES] bayesmh.
paramref may contain factor variables; see fvvarlist.
See [BAYES] bayesian postestimation for features available after
estimation.
Model parameters are regression coefficients {depvar:indepvars} and
ancillary parameters as described in Ancillary model parameters in
[BAYES] bayes: streg.  Use the dryrun option to see the definitions of
model parameters prior to estimation.
For a detailed description of bayesopts, see Options in [BAYES] bayes.

Statistics > Survival analysis > Regression models > Bayesian parametric
survival models

Description

bayes: streg fits a Bayesian parametric survival model to a survival-time
outcome; see [BAYES] bayes and [ST] streg for details.

Examples

Setup
. webuse hip3
. stset

Fit Bayesian Weibull survival model
. bayes: streg protect age, distribution(weibull)

Display coefficients instead of hazard ratios
. bayes, nohr

Display estimates of the shape parameter and its reciprocal
. bayesstats summary (p: exp({ln_p})) (sigma: 1/exp({ln_p}))

Fit Bayesian Weibull regression using uniform priors for all regression
coefficients
. bayes, prior({_t:protect age _cons}, uniform(-20,20)): streg
protect age, distribution(weibull)

Same as above, but use a shortcut notation to refer to all regression
coefficients
. bayes, prior({_t:}, uniform(-20,20)): streg protect age,
distribution(weibull)

Use a different uniform prior for each regression coefficient
. bayes, prior({_t:protect}, uniform(-5,5)) prior({_t:age},
uniform(0,1)) prior({_t:_cons}, uniform(-20,20)): streg protect
age, distribution(weibull)

Fit Bayesian Weibull survival model with ancillary variable male; use
standard deviation of 10 of the default normal prior for regression
coefficients and display dots as iterations are performed
. bayes, normalprior(10) dots: streg protect age,
distribution(weibull) ancillary(male)

Same as above, but also increase the burn-in period to 3,000 from the
default of 2,500 and specify random-number seed for reproducibility
. bayes, normalprior(10) dots burnin(3000) rseed(12345): streg
protect age, distribution(weibull) ancillary(male)

Examine the diagnostic plot for {ln_p:male}
. bayesgraph diagnostic {ln_p:male}

Save MCMC results on replay
. bayes, saving(mymcmc)

Stored results

See Stored results in [BAYES] bayesmh.

```