Learn R Programming

BayHaz (version 0.1-3)

CPPpostSample: Function to Sample Hazard Rates from CPP Posteriors

Description

A function to generate a random sample of hazard rates from the posterior distribution originated by a CPP prior through the observation of a sequence of possibly right censored times to event.

Usage

CPPpostSample(hyp, times, obs = NULL, mclen = 10, burnin = 0, thin = 1, lab = FALSE)

Arguments

hyp
list of hyperparameters (as generated by CPPpriorElicit)
times
vector of (possibly right censored) times to event
obs
vector of censoring indicators (0 = censored, 1 = exact)
mclen
requested sample size
burnin
burn-in parameter
thin
thinning parameter
lab
logical: should latent labels be returned?

Value

hyp
list of hyperparameters identifying the CPP prior that originated the posterior distribution from which the sample was extracted (copy of the input argument)
dat
dataframe with two variables (times and obs) containing the observations on which the posterior distribution is based
burnin
burn-in parameter used (copy of the input argument)
thin
thinning parameter used (copy of the input argument)
sgm
matrix with mclen rows (and hyp$F columns) containing the CPP jump-times
xi0
matrix with mclen rows (and just one column) containing the jump-sizes in the origin
csi
matrix with mclen rows (and hyp$F columns) containing the CPP jump-sizes
gam
matrix with mclen rows (and length(times) columns) containing the latent labels (NULL if lab is FALSE)

Details

A random scan (random start) Gibbs sampler (with slice sampling updating of jump-times) is used to generate a Markov chain sample of length mclen from the posterior distribution originated by hyp through the observation of times and obs; see La Rocca (2005).

The first burnin states of the Markov chain are discarded, then one every thin is kept.

If obs is NULL, it is assumed that all observations are exact (no censoring).

References

Luca La Rocca (2005). On Bayesian Nonparametric Estimation of Smooth Hazard Rates with a View to Seismic Hazard Assessment. Research Report n. 38-05, Department of Social, Cognitive and Quantitative Sciences, Reggio Emilia, Italy.

See Also

BayHaz-package, CPPevalHR, CPPplotHR, CPPpost2mcmc

Examples

Run this code
# set RNG seed (for example reproducibility only)
set.seed(1234)

# select a CPP prior distribution
hypars<-CPPpriorElicit(r0 = 0.1, H = 1, T00 = 50, M00 = 2)
# load a data set
data(earthquakes)

# generate a posterior sample
post<-CPPpostSample(hypars, times = earthquakes$ti, obs = earthquakes$ob)

Run the code above in your browser using DataLab