Learn R Programming

ExceedanceTools (version 1.2.0)

confreg: Construct confidence regions for exceedance (excurions) sets.

Description

confreg constructs confidence regions for the exceedance (excursions) sets of geostatistical processes.

Usage

confreg(obj, ...)

## S3 method for class 'jointPredictiveSample': confreg(obj, level, conf.level = 0.95, direction = ">", type = "o", method = 1, statistic = 1, ...)

Arguments

obj
An object of class jointPredictiveSample.
level
The threshold level for the exceedance region.
conf.level
The confidence level of the confidence region. Default is 0.95.
direction
The direction of the exceedance region. ">" indicates the exceedance region is values above a threshold, while "<"< code=""> indicates values below a threshold.
type
"o" indicates on outer confidence region while "i" indicates in inner confidence region.
method
If method == 1, then the region is constructed using a (test) statistic based procedure. If method == 2, then the region is constructed directly.
statistic
The type of statistic to use if method == 1. If statistic == 1, then the statistic at each site is (prediction - level)/sqrt(mse). If statistic == 2, then the statistic at each site is (prediction - level)/E[(Y - l
...
Currently unimplemented.

Value

  • Returns an object of class confreg with the following components:
  • confidenceThe sites included in the confidence region.
  • complementThe complement of the confidence region.

Details

If type == "o", then an outer confidence region is constructed. The outer confidence region should entirely contain the true exceedanace region with high confidence. If type == "i", then an inner confidence region is constructed. The inner confidence region should be entirely contained within the true exceedanace region with high confidence.

Examples

Run this code
# Set parameters
n <- 100
mygrid = create.pgrid(0, 1, 0, 1, nx = 5, ny = 4)
n.samples <- 10
burnin.start <- 1
sigmasq <- 1
tausq <- 0.0
phi <- 1
cov.model <- "exponential"
n.report <- 5

# Generate coordinates
coords <- matrix(runif(2 * n), ncol = 2)
pcoords <- mygrid$pgrid
# Construct design matrices
X <- as.matrix(cbind(1, coords))
Xp <- cbind(1, pcoords)

# Specify priors
starting <- list("phi" = phi, "sigma.sq"= sigmasq, "tau.sq" = tausq)
tuning <- list("phi"=0.1, "sigma.sq"=0.1, "tau.sq"=0.1)
priors.1 <- list("beta.Norm"=list(c(1, 2, 1), diag(100, 3)), "phi.Unif"=c(0.00001, 10),
 "sigma.sq.IG"=c(1, 1))

# Generate data
library(SpatialTools)
B <- rnorm(3, c(1, 2, 1), sd = 10)
phi <- runif(1, 0, 10)
sigmasq <- 1/rgamma(1, 1, 1)
V <- simple.cov.sp(D = dist1(coords), cov.model, c(sigmasq, 1/phi), error.var = tausq,
 smoothness = nu, finescale.var = 0)
y <- X %*% B + rmvnorm(1, rep(0, n), V) + rnorm(n, 0, sqrt(tausq))

# Create spLM object
library(spBayes)
m1 <- spBayes::spLM(y ~ X - 1, coords = coords, starting = starting, tuning = tuning,
 priors = priors.1, cov.model = cov.model, n.samples = n.samples, verbose = FALSE,
 n.report = n.report)

# Sample from joint posterior predictive distribution
y1 <- spLMPredictJoint(m1, pred.coords = pcoords, pred.covars = Xp,
 start = burnin.start, verbose = FALSE, method = "chol")
myconf = confreg(y1, level = quantile(y, .5), direction = ">", type = "o", method = 1,
 statistic = 1)

Run the code above in your browser using DataLab