Skip to contents

Compute bootstrap confidence intervals for functional statistics such as the mean function, depth values, or regression coefficients.

Usage

fdata.bootstrap.ci(
  fdataobj,
  statistic,
  n.boot = 200,
  alpha = 0.05,
  method = c("percentile", "basic", "normal"),
  seed = NULL
)

Arguments

fdataobj

An object of class 'fdata'.

statistic

A function that computes the statistic of interest. Must take an fdata object and return a numeric vector.

n.boot

Number of bootstrap replications (default 200).

alpha

Significance level for confidence intervals (default 0.05 for 95 percent CI).

method

CI method: "percentile" for simple percentile method, "basic" for basic bootstrap, "normal" for normal approximation (default "percentile").

seed

Optional seed for reproducibility.

Value

A list of class 'fdata.bootstrap.ci' with components:

estimate

The statistic computed on the original data

ci.lower

Lower confidence bound

ci.upper

Upper confidence bound

boot.stats

Matrix of bootstrap statistics (n.boot x length(statistic))

alpha

The significance level used

method

The CI method used

Examples

# Create functional data
t <- seq(0, 1, length.out = 50)
X <- matrix(0, 20, 50)
for (i in 1:20) X[i, ] <- sin(2*pi*t) + rnorm(50, sd = 0.1)
fd <- fdata(X, argvals = t)

# Bootstrap CI for the mean function (returns numeric vector)
ci_mean <- fdata.bootstrap.ci(fd,
  statistic = function(x) as.numeric(mean(x)$data),
  n.boot = 100)

# Bootstrap CI for depth values
ci_depth <- fdata.bootstrap.ci(fd,
  statistic = function(x) depth.FM(x),
  n.boot = 100)