Calcualte simultaneous confidence sets according to Besag et al. (1995) from a empirical joint distribution of a parameter vector. Joint empirical distributions might be obtained from WinBUGS or OpenBUGS calls.
1 2 3 4 5 6 7 8 9 10 11 12 13 
x 
a matrix NtimesP matrix or an object of class 
conf.level 
a single numeric value between 0.5 and 1, the simultaneous confidence level 
alternative 
a single character string, one of 
whichp 
a single character string, naming an element of the 
... 
further arguments, currently not used 
Let P be the number of parameters in the parameter vector and N be the total number of values obtained for the empirical joint distribution of the parameter vector, e.g. as can be obtaine e.g., from Gibbs sampling.
An object of class "SCSnp", a list with elements
conf.int 
a Ptimes2 matrix containing the lower and upper confidence limits 
estimate 
a numeric vector of length P, containing the medians of the P marginal empirical distributions 
x 
the input object 
k 
the number of values outside the SCS, i.e. conf.level*N 
N 
the number of values used to construct the confidence set 
conf.level 
a single numeric value, the nominal confidence level, as input 
alternative 
a single character string, as input 
Frank Schaarschmidt, adapting an earliere version of Gemechis D. Djira
Besag J, Green P, Higdon D, Mengersen K (1995): Bayesian Computation and Stochastic Systems. Statistical Science 10 (1), 366.
CInp
for a wrapper to quantile
to compute simple percentile intervals on each of P marginal distributions
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19  # Assume a 1000 times 4 matrix of 4 mutually independent
# normal variables:
X<cbind(rnorm(1000), rnorm(1000), rnorm(1000), rnorm(1000))
SCSts<SCSnp(x=X, conf.level=0.9, alternative="two.sided")
SCSts
SCS<SCSts$conf.int
in1<X[,1]>=SCS[1,1] & X[,1]<=SCS[1,2]
in2<X[,2]>=SCS[2,1] & X[,2]<=SCS[2,2]
in3<X[,3]>=SCS[3,1] & X[,3]<=SCS[3,2]
in4<X[,4]>=SCS[4,1] & X[,4]<=SCS[4,2]
sum(in1*in2*in3*in4)

Questions? Problems? Suggestions? Tweet to @rdrrHQ or email at ian@mutexlabs.com.
All documentation is copyright its authors; we didn't write any of that.