boot.iid {animation}R Documentation

Demonstrate bootstrapping for iid data

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

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.name/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


[Package animation version 2.5 Index]