This function constructs simultaneous confidence regions (SCRs) for upper and lower excursion sets, and interval sets from simultaneous confidence bands (SCBs). It allows estimation of inner and outer confidence region under single or multiple thresholds. Visualization of the confidence region is also included, along with a containment check for the coverage of true or estimated functions.
scb_to_cs(
scb_up,
scb_low,
levels,
true_mean = NULL,
est_mean = NULL,
x1 = NULL,
x2 = NULL,
type = "upper",
return_contain_only = FALSE,
return_plot = FALSE,
xlab = NULL,
ylab = NULL
)A list containing the following components:
A vector (or list) of threshold levels used to define the
confidence sets. Same as the input levels.
(Optional) A list of logical matrices indicating whether each
point is within the simultaneous inner confidence set for each level.
Returned only when return_contain_only = FALSE and type != "two-sided".
(Optional) A list of logical matrices indicating whether each
point is within the simultaneous outer confidence set for each level.
Returned only when return_contain_only = FALSE and type != "two-sided".
(Two-sided only) A list of logical matrices
indicating lower bound containment (for type = "two-sided" and return_contain_only = FALSE).
(Two-sided only) A list of logical matrices
indicating upper bound containment (for type = "two-sided" and return_contain_only = FALSE).
A logical vector indicating
whether the true mean is fully contained within each level's simultaneous
inner and outer confidence region. Returned only if true_mean is provided.
A single logical value indicating whether the true mean
is contained in all levels' simultaneous inner and outer confidence region.
Returned only if true_mean is provided.
(Optional) A list of ggplot2 objects for visualizing the
SCBs and simultaneous confidence region across all levels,
returned when return_plot = TRUE. Includes both a combined plot and
individual plots per level.
A numeric vector (1D) or matrix (2D) containing the upper simultaneous confidence interval.
A numeric vector (1D) or matrix (2D) containing
the lower bounds of the simultaneous confidence bands.
Dimensions of scb_up and scb_low must match.
A numeric vector or list of scalers for different levels or matrix
containing interval sets to construct the confidence sets.
If type = "upper", "lower", or "two-sided", levels should be a vector.
"upper" represents upper excursion sets, and "lower" represents lower excursion sets.
If "two-sided" option is chosen, will estimate only outer CSs for both upper
and lower excursion sets.
If type = "interval", then levels should be a list
with two named elements: low and up,
corresponding to the bounds of the interval [low, up].
Optional matrix of the true mean function.
Should have the same dimension as scb_up and scb_low.
Optional matrix of the estimated mean function,
used for plotting if true_mean is not available.
Should have the same dimension as scb_up and scb_low.
A numeric vector of coordinates for the first dimension used
for plotting the inner and outer confidence region. Default is NULL.
Dimension of x1 must match the first dimension of scb_up and scb_low.
A numeric vector of coordinates for the second dimension used
for plotting inner and outer confidence region. Default is NULL.
Dimension of x1 must match the second dimension of scb_up and scb_low.
A character string specifying the type of inverse set to construct
if levels are not a matrix. Choices are "upper", "lower", "two-sided"
or "interval". Notice that "two-sided" and "interval" type is not available for
plotting (return_plot = TRUE).
Logical. If TRUE, only return a matrix/logical
map indicating which point is contained within two types of CSs across all levels.
Logical. If TRUE, return a ggplot object for visualizing
the inner and outer confidence region.
A character for the name of the x axis used for plotting the inner and outer confidence region. Default is NULL.
A character for the name of the y axis used for plotting the inner and outer confidence region. Default is NULL.
Ren, J., Telschow, F. J. E., & Schwartzman, A. (2024). Inverse set estimation and inversion of simultaneous confidence intervals. Journal of the Royal Statistical Society: Series C (Applied Statistics), 73(4), 1082–1109. tools:::Rd_expr_doi("10.1093/jrsssc/qlae027")
set.seed(262)
x1 <- rnorm(100)
x2 <- rnorm(100)
y <- -1 + x1 - 0.5 * x2 + rnorm(100,0,sqrt(2))
df <- data.frame(x1 = x1, x2 = x2, y = y)
grid <- data.frame(x1 = seq(-1, 1, length.out = 100), x2 = seq(-1, 1, length.out = 100))
model <- "y ~ x1 + x2 "
result <- SCB_linear_outcome(df_fit = df, model = model, grid_df = grid, n_boot = 100)
scb_to_cs(result$scb_up, result$scb_low, c(-1, -0.5, 0.5, 1),
x1 = grid$x1, x2 = grid$x2, est_mean = results$Mean)
Run the code above in your browser using DataLab