cred: Estimate credible interval.

credR Documentation

Estimate credible interval.

Description

Estimate credible interval from weighted samples.

Usage

  cred(x, x0, w = NULL, cred.int = 0.95)

Arguments

x

Vector of random samples of variable.

x0

Mean of median of variable.

w

Weight > 0 assigned to each sample. If w = NULL, all weights are the same.

cred.int

Credible interval must contain probability mass of at least this amount. A number between 0 and 1.

Details

Credible interval [a,b] is defined as smallest interval containing x0 that contains cred.int of the probability mass. Note that the credible interval is not necessarily symmetric about x0. (Other definitions of the credible interval are possible.)

The algorithm is quadratic in the length of x (and w), so should not be used for large numbers of samples.

Value

list(a = a,b = b).

Author(s)

Peter Carbonetto peter.carbonetto@gmail.com

References

P. Carbonetto and M. Stephens (2012). Scalable variational inference for Bayesian variable selection in regression, and its accuracy in genetic association studies. Bayesian Analysis 7, 73–108.

Examples

  x   <- rnorm(100)
  out <- cred(x,mean(x),cred.int = 0.68)

varbvs documentation built on June 7, 2023, 5:43 p.m.