Can simultaneous confidence bands be globally correct but locally unfair?

functional data
bootstrap
simulation
R
A follow-up experiment on local roughness and regional noncoverage probabilities in simultaneous bands using funbootband.
Author

Daniel Koska

Published

December 2, 2026

In my previous post I looked at how well finite Fourier series can represent functional observations with varying degrees of roughness and if the reconstruction affects the coverage of simultaneous confidence and prediction bands constructed with my R package funbootband.

As I have mentioned in Part I, this is only the first step. The thing that caught my attention when reading the paper by Liebl and Reimherr (2023) was the idea that even if a simultaneous band achieves nominal coverage probability, the probability of missing the true function may differ considerably between regions (of different roughness) of the functional domain. That in itself is not overly surprising, but the idea that one can account for these local differences even within a functional data analysis (FDA) framework was new to me. Tbh, in my mind one of the main features of FDA is to solve the multiple comparisons problem, so then dividing curves into different regions kinda contradicted that. It doesn’t … we might get into this in a bit more detail later (see union bound etc.).

Anyway, the working hypothesis for today is that simultaneous bands can be globally correct but locally unfair. This is not necessarily a question of how wide the band is in absolute terms. It is a question of where noncoverage is more likely to occur. In this post, I return to the simulated Matérn curves from Part I to see whether this issue also arises with the current implementation of funbootband. If that is the case, I might have to seriously think about adding a way to account for such regional differences to band(). For this post, I restrict the experiment to confidence bands and independent functional observations since that is what Liebl and Reimherr have done (plus it will hopefully keep the article at a reasonable length).

Global coverage and local noncoverage

A nominal 95% simultaneous confidence band for a population mean function \(\mu(t)\) over \(t\in[0,1]\) is designed to satisfy

\[P\{L(t)\leq\mu(t)\leq U(t)\ \text{for all }t\in[0,1]\}\geq 0.95.\]

In the simulation below, simultaneous coverage is assessed across all 161 grid points. In funbootband, the band takes the form

\[\hat\mu(t)\pm c_\alpha\,\widehat{\mathrm{SE}}\{\hat\mu(t)\},\]

where \(c_\alpha\) is a constant critical value calibrated from the bootstrap distribution of the maximum absolute studentized deviation. The standard error can vary across the domain, but the critical value cannot. While this approach accounts for the dependence structure through resampling, it does not explicitly control where noncoverage is more likely to occur.

Liebl and Reimherr (2023), however, suggest allocating the global error budget across a prespecified partition of the functional domain. Specifically, for regions \(I_1,\ldots,I_J\), they allocate the significance level proportionally to the length of each region:

\[\alpha_j=\alpha\,|I_j|,\]

where \(|I_j|\) denotes the length of region \(I_j\) on the normalized domain \([0,1]\). For example, with four equally sized regions and \(\alpha = 0.05\), each region is allocated one quarter of the global error budget. Consequently, the probability of noncoverage anywhere within each region should not exceed \(\alpha/4 = 0.0125\) (1.25%).

But doesn’t this contradict the idea of simultaneous inference? Not really. The union bound (Boole’s inequality) ensures that

\[P\left(\bigcup_{j=1}^{J}E_j\right) \leq\sum_{j=1}^{J}P(E_j) \leq\sum_{j=1}^{J}\alpha_j=\alpha,\]

where \(E_j\) denotes the event that the true mean falls outside the band at least once within region \(I_j\), and the second inequality assumes that the regional error bounds are satisfied. Importantly, this holds regardless of the dependence between regions.

So rather than circumventing the multiple comparisons problem, Liebl and Reimherr impose an additional constraint on top of global error control (see Definition 2.1 and Proposition 3.2 in their paper). Their adaptive critical value function is designed to satisfy these regional bounds while accounting for local roughness. The actual regional noncoverage probabilities need not be exactly equal to their allocated levels, and imposing more regional constraints can make the band more conservative.

Back to the Matérn curves

I use the three periodic scenarios from Part I (smooth, globally rough and locally rough) with the same mean and covariance functions:

\[Y(t)=\mu(t)+0.6\{\sqrt{1-w(t)^2}Z_s(t)+w(t)Z_r(t)\}.\]

Here \(Z_s\) and \(Z_r\) are independent unit-variance Matérn processes (\(\nu=5/2,\ \ell=0.16\) and \(\nu=3/2,\ \ell=0.045\), respectively). The weight \(w(t)\) controls the local roughness while keeping the theoretical pointwise SD constant at 0.6.

Code for the original Matérn data-generating functions
roughness_weight <- function(t, scenario) {
  if (scenario == "rough_global") return(rep(1, length(t)))
  if (scenario == "rough_local") {
    # Smooth transitions into and out of the rough part of the cycle
    up <- pmax(0, pmin(1, (t - 0.40) / 0.15))
    down <- pmax(0, pmin(1, (0.95 - t) / 0.15))
    return(sin(pi / 2 * sin(pi * up / 2)^2 * sin(pi * down / 2)^2))
  }
  if (scenario %in% c("smooth", "nonperiodic")) return(rep(0, length(t)))
  stop("Unknown scenario: ", scenario)
}

population_mean <- function(t, scenario) {
  mean_curve <- sin(2 * pi * t) + 0.35 * sin(4 * pi * t - 0.7) +
    0.15 * cos(6 * pi * t)
  if (scenario == "nonperiodic") mean_curve <- mean_curve + 0.8 * (t - 0.5)
  mean_curve
}

# Matérn correlation on a circle (only the two nu values used here)
matern_cor <- function(t, nu, ell) {
  d <- abs(sin(pi * outer(t, t, "-"))) / pi
  z <- sqrt(2 * nu) * d / ell
  if (nu == 1.5) return((1 + z) * exp(-z))
  if (nu == 2.5) return((1 + z + z^2 / 3) * exp(-z))
  stop("Unknown nu")
}

# Exclude the duplicated endpoint before taking the Cholesky factor.
# The factors only need to be computed once for the simulation grid.
make_factors <- function(t) {
  u <- head(t, -1)
  list(smooth = chol(matern_cor(u, nu = 2.5, ell = 0.16)),
       rough = chol(matern_cor(u, nu = 1.5, ell = 0.045)))
}

L <- make_factors(t_grid)

draw_gp <- function(R, n) {
  Z <- t(R) %*% matrix(rnorm(nrow(R) * n), ncol = n)
  rbind(Z, Z[1, , drop = FALSE])
}

random_component <- function(t, w, n) {
  R <- if (identical(t, t_grid)) L else make_factors(t)
  # Mix independent processes, keeping the marginal variance constant
  a <- sqrt(pmax(0, 1 - w^2))
  if (all(w == 0)) return(draw_gp(R$smooth, n))
  if (all(w == 1)) return(draw_gp(R$rough, n))
  a * draw_gp(R$smooth, n) + w * draw_gp(R$rough, n)
}

simulate_sample <- function(scenario, t, n = 60L) {
  w <- roughness_weight(t, scenario)
  mu <- population_mean(t, scenario)
  sigma <- 0.60
  Y <- sweep(sigma * random_component(t, w, n), 1, mu, "+")
  future <- mu + as.vector(sigma * random_component(t, w, 1L))
  list(Y = Y, mu = mu, future = future)
}

fourier_Q <- function(T, k) {
  stopifnot(k >= 0, k <= floor((T - 2) / 2))
  u <- (seq_len(T) - 1) / (T - 1)  # same phase convention as funbootband
  D <- matrix(1, nrow = T, ncol = 2L * k + 1L)
  if (k > 0) {
    for (j in seq_len(k)) {
      D[, 2L * j] <- cos(2 * pi * j * u)
      D[, 2L * j + 1L] <- sin(2 * pi * j * u)
    }
  }
  qr.Q(qr(D))
}

project_on_Q <- function(X, Q) {
  X <- as.matrix(X)
  Q %*% crossprod(Q, X)  # least-squares fitted curves
}
Code
Q <- fourier_Q(T_grid, k)

# Same windows as in Part I. Integer grid indices avoid boundary rounding.
regions <- list(Smooth_window = 1L + (8L:48L),
                Rough_window = 1L + (88L:128L))
stopifnot(all(lengths(regions) == 41L))
windows <- data.frame(region = c("Smooth window", "Rough window"),
                      xmin = c(0.05, 0.55), xmax = c(0.30, 0.80))
scenario_factor <- function(x) {
  factor(x, levels = scenarios, labels = unname(scenario_labels[scenarios]))
}

I focus on two equally sized windows, \(I_s=[0.05,0.30]\) and \(I_r=[0.55,0.80]\). Only in the locally rough scenario do these windows systematically differ in stochastic roughness. The smooth and globally rough scenarios therefore serve as controls.

Before investigating regional noncoverage, I want to make sure that Fourier reconstruction preserves the intended differences in local roughness without introducing substantial systematic differences in pointwise variability. I use k.coef = 40 throughout. The true mean lies in the Fourier basis, so mean reconstruction bias cannot explain noncoverage here. As a measure of local roughness, I calculate the RMS of increments of standardized residual curves, divided by the grid spacing.i

Code
roughness_diagnostic <- do.call(rbind, lapply(scenarios, function(s) {
  X <- project_on_Q(examples[[s]], Q)
  centered <- sweep(X, 1, rowMeans(X), "-")
  sd_t <- apply(centered, 1, sd)
  Z <- sweep(centered, 1, sd_t, "/")
  increments <- sweep(Z[-1, , drop = FALSE] -
    Z[-nrow(Z), , drop = FALSE], 1, diff(t_grid), "/")
  mids <- (head(t_grid, -1) + tail(t_grid, -1)) / 2
  rbind(data.frame(t = t_grid, scenario = s, measure = "Pointwise SD",
                   value = sd_t),
        data.frame(t = mids, scenario = s,
                   measure = "Standardized increment RMS / dt",
                   value = sqrt(rowMeans(increments^2))))
}))
roughness_diagnostic$scenario <- scenario_factor(roughness_diagnostic$scenario)
p_roughness <- ggplot(roughness_diagnostic, aes(t, value, color = scenario)) +
  geom_rect(data = windows, aes(xmin = xmin, xmax = xmax, ymin = -Inf,
                                ymax = Inf, fill = region),
            inherit.aes = FALSE, alpha = 0.08, show.legend = FALSE) +
  geom_line(linewidth = 0.7) +
  scale_fill_manual(values = shade_colors) +
  facet_wrap(~ measure, ncol = 1, scales = "free_y") +
  labs(x = "Normalized domain", y = NULL, color = "Scenario") +
  theme_minimal(base_size = 11) + theme(legend.position = "bottom")
p_roughness
Figure 1: Pointwise SD and standardized increment RMS after Fourier reconstruction (40 harmonics), calculated from 300 illustrative curves per scenario.

Figure 1 shows that pointwise variability is broadly comparable across the three scenarios. The intended differences in stochastic roughness, however, are clearly preserved after Fourier reconstruction. In the locally rough scenario, roughness is approximately four times higher in the second highlighted region than in the first. This should provide a suitable setting for investigating whether local roughness affects regional noncoverage probabilities.

Where do the confidence bands fail?

For each scenario I simulate 2000 samples of 60 curves and construct a 95% confidence band using 500 bootstrap resamples. For a region \(I\) its noncoverage probability is

\[p_I=P\{\exists\,t\in I\cap\mathcal G:\ \mu(t)<L(t)\ \text{or}\ \mu(t)>U(t)\},\]

where \(\mathcal G\) denotes the grid. I estimate this probability seperately for both windows and the entire domain. Note that the regional probabilities need not sum to the global probability: both windows can be missed in the same repetition, and misses can also occur elsewhere.

Code for the Monte Carlo coverage experiment
run_coverage <- function(scenarios, M, B, n, alpha, k) {
  records <- vector("list", length(scenarios) * M)
  pointwise <- setNames(vector("list", length(scenarios)), scenarios)
  counter <- 0L

  for (s in scenarios) {
    missed_count <- integer(T_grid)
    width_sum <- numeric(T_grid)
    for (r in seq_len(M)) {
      sample <- simulate_sample(s, t_grid, n = n)
      fit <- funbootband::band(sample$Y, type = "confidence",
                              alpha = alpha, iid = TRUE, B = B, k.coef = k)
      lower <- as.numeric(fit$lower)
      upper <- as.numeric(fit$upper)
      target <- as.numeric(project_on_Q(sample$mu, Q))
      if (r == 1L) {
        stopifnot(isTRUE(all.equal(target, sample$mu, tolerance = 1e-8)),
                  isTRUE(all.equal(as.numeric(fit$mean),
                    as.numeric(project_on_Q(rowMeans(sample$Y), Q)),
                    tolerance = 1e-8)))
      }
      stopifnot(length(lower) == T_grid, length(upper) == T_grid,
                all(is.finite(c(lower, upper))), all(lower <= upper))

      missed <- target < lower | target > upper
      width <- upper - lower
      missed_count <- missed_count + missed
      width_sum <- width_sum + width
      miss_s <- any(missed[regions$Smooth_window])
      miss_r <- any(missed[regions$Rough_window])
      counter <- counter + 1L
      records[[counter]] <- data.frame(
        scenario = s, repetition = r,
        global = any(missed), smooth = miss_s, rough = miss_r,
        both = miss_s && miss_r,
        difference = as.integer(miss_r) - as.integer(miss_s),
        width_smooth = mean(width[regions$Smooth_window]),
        width_rough = mean(width[regions$Rough_window]))
    }
    pointwise[[s]] <- data.frame(scenario = s, t = t_grid,
      noncoverage = missed_count / M, mean_width = width_sum / M)
  }
  list(runs = do.call(rbind, records),
       pointwise = do.call(rbind, pointwise))
}

# Wilson intervals quantify Monte Carlo uncertainty in estimated probabilities.
wilson <- function(p, m, level = 0.95) {
  z <- qnorm(1 - (1 - level) / 2)
  center <- (p + z^2 / (2 * m)) / (1 + z^2 / m)
  half <- z * sqrt(p * (1 - p) / m + z^2 / (4 * m^2)) /
    (1 + z^2 / m)
  data.frame(lo = pmax(0, center - half), hi = pmin(1, center + half))
}
Run the experiment and summarize the results
set.seed(20261203)
mc <- run_coverage(scenarios, M, B, n, alpha, k)
runs <- mc$runs
pointwise <- mc$pointwise
pointwise$scenario <- scenario_factor(pointwise$scenario)

rates <- do.call(rbind, lapply(scenarios, function(s) {
  x <- runs[runs$scenario == s, ]
  p <- vapply(x[c("global", "smooth", "rough")], mean, numeric(1))
  data.frame(scenario = s, region = names(p), p = unname(p),
             wilson(unname(p), nrow(x)))
}))
rates$scenario <- scenario_factor(rates$scenario)
rates$region <- factor(rates$region, levels = c("global", "smooth", "rough"),
                       labels = c("Entire domain", "Smooth window", "Rough window"))

paired <- do.call(rbind, lapply(scenarios, function(s) {
  x <- runs[runs$scenario == s, ]
  d <- mean(x$difference)
  se <- sd(x$difference) / sqrt(nrow(x))
  data.frame(scenario = s, difference = d, mcse = se,
             lo = d - qnorm(0.975) * se, hi = d + qnorm(0.975) * se,
             both = mean(x$both), width_smooth = mean(x$width_smooth),
             width_rough = mean(x$width_rough))
}))
paired$scenario <- scenario_factor(paired$scenario)

get_rate <- function(s, region) {
  x <- rates[rates$scenario == scenario_labels[[s]] & rates$region == region, ]
  stopifnot(nrow(x) == 1L)
  x$p
}
pct <- function(p) sprintf("%.2f%%", 100 * p)
pp <- function(p) sprintf("%+.2f pp", 100 * p)
local <- paired[paired$scenario == "Locally rough", ]
global_local <- rates[rates$scenario == "Locally rough" &
                        rates$region == "Entire domain", ]
Code
benchmarks <- data.frame(region = levels(rates$region),
                         p = c(alpha, alpha / 4, alpha / 4))
benchmarks$region <- factor(benchmarks$region, levels = levels(rates$region))
p_regional <- ggplot(rates, aes(scenario, 100 * p, color = region)) +
  geom_hline(data = benchmarks, aes(yintercept = 100 * p),
             linetype = "dashed", color = "grey35") +
  geom_errorbar(aes(ymin = 100 * lo, ymax = 100 * hi), width = 0.14) +
  geom_point(size = 2.8) +
  facet_wrap(~ region, nrow = 1) +
  scale_color_manual(values = c("Entire domain" = "grey30", shade_colors)) +
  scale_y_continuous(limits = c(0, NA)) +
  labs(x = NULL, y = "Noncoverage probability (%)") +
  theme_minimal(base_size = 11) +
  theme(legend.position = "none", axis.text.x = element_text(angle = 25, hjust = 1))
p_regional
Figure 2: Estimated probabilities of missing the true mean anywhere in the entire domain or in either prespecified window. Error bars are individual 95% Wilson Monte Carlo intervals. Dashed lines indicate the nominal global noncoverage level (5%) and the length-proportional regional benchmark (1.25%).

In the locally rough scenario, global coverage is 94.35%. The global noncoverage interval includes the nominal 5%. Regional noncoverage is 1.15% in the smooth window and 2.25% in the rough window.

The dashed regional lines indicate the Liebl–Reimherr benchmark of \(0.05\times0.25=0.0125\), not a regional guarantee of funbootband. The paired difference (rough minus smooth) is +1.10 pp (MCSE 0.41 pp, approximate 95% Monte Carlo interval +0.31 pp to +1.89 pp). The rough window is missed more frequently in this experiment.

No comparable regional imbalance is apparent in the two control scenarios (smooth and globally rough). THis suggests that the observed imbalance is associated with local differences in stochastic roughness rather than roughness per se.

What about individual grid points?

Code
p_pointwise <- ggplot(pointwise, aes(t, 100 * noncoverage)) +
  geom_rect(data = windows, aes(xmin = xmin, xmax = xmax, ymin = -Inf,
                                ymax = Inf, fill = region),
            inherit.aes = FALSE, alpha = 0.10) +
  geom_line(linewidth = 0.6, color = "grey25") +
  scale_fill_manual(values = shade_colors) +
  facet_wrap(~ scenario, ncol = 1) +
  labs(x = "Normalized domain", y = "Pointwise noncoverage (%)", fill = NULL) +
  theme_minimal(base_size = 11) + theme(legend.position = "bottom")
p_pointwise
Figure 3: Pointwise empirical noncoverage of the true mean. These are descriptive estimates, not simultaneous confidence intervals for the noncoverage function.

Figure 3 shows that pointwise noncoverage is generally higher in the smooth scenario than in the other two scenarios. More interestingly, in the locally rough scenario, pointwise noncoverage does not appear to differ systematically between the two highlighted windows, despite the pronounced difference in regional noncoverage observed in Figure 2. This illustrates an important distinction: even with similar pointwise noncoverage probabilities, a rough region can have more effectively distinct opportunities for a band crossing.

Gretchenfrage: Should I make the calibration locally adaptive?

The results here tell me that when curves look like the ones simulated here (with certain regions displaying clearly higher roughness), it might be a good idea to implement a locally adaptive calibration method in funbootband. This could produce narrower bands in smoother regions and wider bands in rougher regions, potentially improving local statistical power while maintaining global simultaneous coverage.

What I find particularly interesting is the possibility of adapting the critical value without leaving the bootstrap framework of funbootband. Rather than calculating one maximum per bootstrap replicate, I could, e.g., calculate maxima over a partition of the domain.

Regional quantiles at levels \(1-\alpha|I_j|\) could then yield a piecewise constant critical value function \(c_\alpha(t)\). With valid regional calibration, the union bound ensures global control, though potentially conservatively. Alternatively, the joint bootstrap distribution of the maxima could be used for global recalibration, but this would not automatically preserve the strict regional error bounds.

The aim would be to change where the band allocates uncertainty, not necessarily to make it uniformly wider or narrower. As with Part I, this is obviously just an illustrative experiment rather than a comprehensive validation.

Reproducibility details
funbootband version: 0.3.1
R version: R version 4.6.2 (2026-10-29)
M = 2000; B = 500; n = 60; k.coef = 40
Monte Carlo seed: 20261203