Learn R Programming

BSagri (version 0.1-10)

SCSnp: Simultaneous confidence sets from empirical joint distribution.

Description

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.

Usage

# S3 method for default
SCSnp(x, conf.level = 0.95,
 alternative = "two.sided", ...)

# S3 method for bugs SCSnp(x, conf.level = 0.95, alternative = "two.sided", whichp = NULL, ...)

# S3 method for CCRatio SCSnp(x, ...)

# S3 method for CCDiff SCSnp(x, ...)

Arguments

x

a matrix N-times-P matrix or an object of class CCRatio or CCDiff

conf.level

a single numeric value between 0.5 and 1, the simultaneous confidence level

alternative

a single character string, one of "two.sided", "less", "greater", for two-sided, upper and lower limits

whichp

a single character string, naming an element of the sims.list if x is a bugs object, ignored otherwise

further arguments, currently not used

Value

An object of class "SCSnp", a list with elements

conf.int

a P-times-2 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

Details

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.

References

Besag J, Green P, Higdon D, Mengersen K (1995): Bayesian Computation and Stochastic Systems. Statistical Science 10 (1), 3-66.

See Also

CInp for a wrapper to quantile to compute simple percentile intervals on each of P marginal distributions

Examples

Run this code
# NOT RUN {

# 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)


# }

Run the code above in your browser using DataLab