View source: R/bootstrapBand.R
bootstrapBand | R Documentation |
The function bootstrapBand
computes a uniform symmetric confidence band around a function of the data X
, evaluated on a Grid
, using the bootstrap algorithm. See Details and References.
bootstrapBand(
X, FUN, Grid, B = 30, alpha = 0.05, parallel = FALSE,
printProgress = FALSE, weight = NULL, ...)
X |
an |
FUN |
a function whose inputs are an |
Grid |
an |
B |
the number of bootstrap iterations. |
alpha |
|
parallel |
logical: if |
printProgress |
if |
weight |
either NULL, a number, or a vector of length |
... |
additional parameters for the function |
First, the input function FUN
is evaluated on the Grid
using the original data X
. Then, for B
times, the bootstrap algorithm subsamples n
points of X
(with replacement), evaluates the function FUN
on the Grid
using the subsample, and computes the \ell_\infty
distance between the original function and the bootstrapped one. The result is a sequence of B
values. The (1-alpha
) confidence band is constructed by taking the (1-alpha
) quantile of these values.
The function bootstrapBand
returns a list with the following elements:
width |
number: ( |
fun |
a numeric vector of length |
band |
an |
Jisu Kim and Fabrizio Lecci
Wasserman L (2004). "All of statistics: a concise course in statistical inference." Springer.
Fasy BT, Lecci F, Rinaldo A, Wasserman L, Balakrishnan S, Singh A (2013). "Statistical Inference For Persistent Homology: Confidence Sets for Persistence Diagrams." (arXiv:1303.7117). Annals of Statistics.
Chazal F, Fasy BT, Lecci F, Michel B, Rinaldo A, Wasserman L (2014). "Robust Topological Inference: Distance-To-a-Measure and Kernel Distance." Technical Report.
kde
, dtm
# Generate data from mixture of 2 normals.
n <- 2000
X <- c(rnorm(n / 2), rnorm(n / 2, mean = 3, sd = 1.2))
# Construct a grid of points over which we evaluate the function
by <- 0.02
Grid <- seq(-3, 6, by = by)
## bandwidth for kernel density estimator
h <- 0.3
## Bootstrap confidence band
band <- bootstrapBand(X, kde, Grid, B = 80, parallel = FALSE, alpha = 0.05,
h = h)
plot(Grid, band[["fun"]], type = "l", lwd = 2,
ylim = c(0, max(band[["band"]])), main = "kde with 0.95 confidence band")
lines(Grid, pmax(band[["band"]][, 1], 0), col = 2, lwd = 2)
lines(Grid, band[["band"]][, 2], col = 2, lwd = 2)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.