BPSpostSample {BayHaz} | R Documentation |
A function to generate a random sample of hazard rates from the posterior distribution originated by a first order autoregressive BPS prior through the observation of a sequence of possibly right censored times to event.
BPSpostSample(hyp, times, obs = NULL, mclen = 10, burnin = 0, thin = 1, df = 10, etastar = NULL)
hyp |
list of hyperparameters (as generated by BPSpriorElicit ) |
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 |
df |
degrees of freedom for the multivariate Student-t proposal distribution |
etastar |
posterior mode and corresponding hessian in list format (as generated by optim with hessian = TRUE ) |
A Markov chain sample of length mclen
from the posterior distribution
originated by hyp
through the observation of times
and obs
is generated
using a taylored proposal density Metropolis-Hastings sampler (starting at the posterior mode);
see Chib & Greenberg (1995).
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).
A list with seven components:
hyp |
list of hyperparameters identifying the BPS 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) |
df |
degrees of freedom used for the multivariate Student-t proposal distribution (copy of the input argument) |
etastar |
posterior mode and corresponding hessian in list format (copy of the input argument
or computed via optim if the input argument was NULL) |
eta |
matrix with mclen rows (and length(hyp$knots)-hyp$ord columns) containing the spline weights |
If mclen
is equal to zero eta
will be a chain of length one containing the posterior mode.
Chib, S. & E. Greenberg (1995). Understanding the Metropolis-Hastings algorithm. American Statistician 49, 327–335.
BayHaz-package
, BPSevalHR
, BPSplotHR
, BPSpost2mcmc
# set RNG seed (for example reproducibility only) set.seed(1234) # select a BPS prior distribution hypars<-BPSpriorElicit(r0 = 0.1, H = 1, T00 = 50, ord = 4, G = 3, c = 0.9) # load a data set data(earthquakes) # find the posterior mode postmode<-BPSpostSample(hypars, times = earthquakes$ti, obs = earthquakes$ob, mclen = 0) # evaluate the posterior mode hazard rate at year multiples BPSevalHR(time = seq(0,50), sample = postmode) # generate a posterior sample post<-BPSpostSample(hypars, times = earthquakes$ti, obs = earthquakes$ob, etastar = postmode$etastar) # plot some posterior hazard rate summaries BPSplotHR(post, tu = "Year")