Description Usage Arguments Details Value References See Also
View source: R/SamplePosteriorDepGamma.R
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.
1 2 3 4 5 6 7 8 | SamplePosteriorDepGamma(
failures,
exposures,
N = 1000,
alpha.dep = 1,
alpha0.dep = 1.5,
beta0.dep = 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.dep |
The main parameter α for the dependent Gamma
prior, as described in the documentation for BayesSurv. It is
recommended to take |
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. |
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 dependent 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.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.