SamplePosteriorIndepGamma {BayesSurvival} R Documentation

## Draw samples from the posterior for the hazard, using the piecewise exponential (histogram) prior with independent Gamma heights

### Description

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.

### Usage

```SamplePosteriorIndepGamma(
failures,
exposures,
N = 1000,
alpha.indep = 1.5,
beta.indep = 1
)
```

### Arguments

 `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.

### 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 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.

### 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.

[Package BayesSurvival version 0.2.0 Index]