You can fit parametric survival models in Stata using
streg. You can fit multilevel parametric survival models using
mestreg. You can now fit Bayesian parametric survival models by simply typing
bayes: in front of
Consider a dataset in which we model the time until hip fracture as a function of age and whether the patient wears a hip-protective device (variable
protect). Let's fit a Bayesian Weibull model to these data and compare the results with the classical analysis.
First, we declare our survival data.
Then, we fit a Weibull survival model using
Finally, to fit a Bayesian survival model, we simply prefix the above
streg command with
Because the default priors used are noninformative for these data, the above results are similar to those obtained from
streg. Instead of the default priors, you can specify your own; see Custom priors.
The hazard ratios are reported by default, but you can use the
nohr option with
bayes, during estimation or on replay, to report coefficients. Alternatively, you can specify this option with
streg during estimation.
bayes: streg reports only the log of the shape parameter. We can use the
bayesstats summary command [BAYES]
bayesstats summary) to obtain the estimates of the shape parameter and its reciprocal.