SamplePosteriorDepGamma {BayesSurvival} | R Documentation |
Draw samples from the posterior for the hazard, using the piecewise exponential (histogram) prior with dependent Gamma heights
Description
The sampler is described in the Supplement to Castillo and Van der Pas (2020) and uses MCMC within Gibbs, with a Gamma proposal with shape parameter equal to the number of events in each interval plus some epsilon (to prevent proposals equal to zero if there are no events in an interval) and rate parameter equal to the parameter alpha (set by the user) divided by histogram height on the previous interval, plus the total amount of time all individuals were exposed during this interval. Most users of the package will not work with this function directly, but instead use the main function BayesSurv, in which this particular function is incorporated.
Usage
SamplePosteriorDepGamma(
failures,
exposures,
N = 1000,
alpha.dep = 1,
alpha0.dep = 1.5,
beta0.dep = 1
)
Arguments
failures |
A vector of length |
exposures |
A vector of length |
N |
The number of draws to take. |
alpha.dep |
The main parameter |
alpha0.dep |
The shape parameter for the Gamma prior on the histogram
height for the first interval. It is recommended to take |
beta0.dep |
The rate parameter for the Gamma prior on the histogram height for the first interval. |
Details
The samples returned by this function are draws from the posterior for the
hazard function. To obtain draws from the posterior for the cumulative
hazard, one can use numerical integration. One way to achieve this is by
first finding the values of the cumulative hazard at the end of each interval,
e.g. by t(apply(samples*time.max/K, 1, cumsum))
, where samples
is the output from the present function and time.max
and K
are
as described for BayesSurv, and then using approxfun()
to linearly
interpolate in between. To obtain posterior samples from the survival, one
could then use SurvivalFromCumhaz.
Value
samples |
A |
References
Castillo and Van der Pas (2020). Multiscale Bayesian survival analysis. <arXiv:2005.02889>.
See Also
BayesSurv, which computes the posterior mean and credible bands for the cumulative hazard and survival functions, as well as the posterior mean for the hazard. Within BayesSurv, the present function is called.