Learn R Programming

varbvs (version 2.6-10)

cred: Estimate credible interval.

Description

Estimate credible interval from weighted samples.

Usage

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

Value

list(a = a,b = b).

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.

Author

Peter Carbonetto peter.carbonetto@gmail.com

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.

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

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

Run the code above in your browser using DataLab