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 K (the total number of intervals), containing for each interval the number of individuals who had an event during that interval. |
exposures |
A vector of length K (the total number of intervals), containing for each interval the total amount of time all individuals together were under follow-up during that interval. |
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 N by K (the number of draws by the number of intervals) matrix, with each row containing a draw from the posterior for the hazard, based on a histogram prior with independent Gamma heights. |
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.