boot.iid: Demonstrate bootstrapping for iid data

Description Usage Arguments Details Value Note Author(s) References See Also

View source: R/boot.iid.R

Description

Use a sunflower scatter plot to illustrate the results of resampling, and a histogram to show the distribution of the statistic of interest.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
boot.iid(
  x = runif(20),
  statistic = mean,
  m = length(x),
  mat = matrix(1:2, 2),
  widths = rep(1, ncol(mat)),
  heights = rep(1, nrow(mat)),
  col = c("black", "red", "bisque", "red", "gray"),
  cex = c(1.5, 0.8),
  main,
  ...
)

Arguments

x

a numerical vector (the original data).

statistic

A function which returns a value of the statistic of interest when applied to the data x.

m

the sample size for bootstrapping (m-out-of-n bootstrap)

mat, widths, heights

arguments passed to layout to set the layout of the two graphs

col

a character vector of length 5 specifying the colors of: points of original data, points for the sunflowerplot, rectangles of the histogram, the density line, and the rug.

cex

a numeric vector of length 2: magnification of original data points and the sunflowerplot points.

main

a character vector of length 2: the main titles of the two graphs.

...

other arguments passed to hist

Details

This is actually a very naive version of bootstrapping but may be useful for novices. By default, the circles denote the original dataset, while the red sunflowers (probably) with leaves denote the points being resampled; the number of leaves just means how many times these points are resampled, as bootstrap samples with replacement. The x-axis is the sample values, and y-axis is the indices of sample points.

The whole process has illustrated the steps of resampling, computing the statistic and plotting its distribution based on bootstrapping.

Value

A list containing

t0

The observed value of 'statistic' applied to 'x'.

tstar

Bootstrap versions of the 'statistic'.

Note

The maximum times of resampling is specified in ani.options('nmax').

Author(s)

Yihui Xie

References

Examples at https://yihui.org/animation/example/boot-iid/

There are many references explaining the bootstrap and its variations.

Efron, B. and Tibshirani, R. (1993) An Introduction to the Bootstrap. Chapman & Hall.

See Also

sunflowerplot


animation documentation built on Oct. 7, 2021, 9:18 a.m.