credible.region {bayesSurv} | R Documentation |
See the two references for more detail.
credible.region(sample, probs=c(0.90, 0.975))
sample |
a data frame or matrix with sampled values (one column = one parameter) |
probs |
probabilities for which the credible regions are to be computed |
A list (one component for each confidence region) of length equal to
length(probs)
. Each component of the list is a matrix with two
rows (lower and upper limit) and as many columns as the number of
parameters giving the confidence region.
Arnost Komarek arnost.komarek@med.kuleuven.be
Besag, J., Green, P., Higdon, D. and Mengersen, K. (1995). Bayesian computation and stochastic systems (with Discussion). Statistical Science, 10, 3 - 66. page 30
Held, L. (2004). Simultaneous inference in risk assessment; a Bayesian perspective In: COMPSTAT 2004, Proceedings in Computational Statistics (J. Antoch, Ed.), 213 - 222, page 214
m <- 10000 sample <- data.frame(x1=rnorm(m), x2=rnorm(m), x3=rnorm(m)) probs <- c(0.70, 0.90, 0.95) CR <- credible.region(sample, probs=probs) for (kk in 1:length(CR)){ suma <- sum(sample$x1 >= CR[[kk]]["Lower", "x1"] & sample$x1 <= CR[[kk]]["Upper", "x1"] & sample$x2 >= CR[[kk]]["Lower", "x2"] & sample$x2 <= CR[[kk]]["Upper", "x2"] & sample$x3 >= CR[[kk]]["Lower", "x3"] & sample$x3 <= CR[[kk]]["Upper", "x3"]) show <- c(suma/m, probs[kk]) names(show) <- c("Empirical", "Desired") print(show) }