SamplePosteriorIndepGamma {BayesSurvival} | R Documentation |
The sampler is described in the Supplement to Castillo and Van der Pas (2020). 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.
SamplePosteriorIndepGamma(
failures,
exposures,
N = 1000,
alpha.indep = 1.5,
beta.indep = 1
)
failures |
A vector of length |
exposures |
A vector of length |
N |
The number of draws to take. |
alpha.indep |
The shape parameter for the Gamma prior on the histogram height for each interval. |
beta.indep |
The rate parameter for the Gamma prior on the histogram height for each interval. |
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.
samples |
A |
Castillo and Van der Pas (2020). Multiscale Bayesian survival analysis. <arXiv:2005.02889>.
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.