Learn R Programming

distillery (version 1.2-1)

booter: Bootstrap Resampling

Description

Generate B bootstrap replicates of size rsize and apply a statistic to them. Can do IID or Circular Block Bootstrap (CBB) methods.

Usage

booter(x, statistic, B, rsize, block.length = 1, v.terms, shuffle = NULL,
    replace = TRUE, ...)

Arguments

x

Original data series. May be a vector, matrix or data frame object.

statistic

Function that minimally takes arguments: data and . The argument data must be the input data for which resamples are taken. Must return a vector of all desired statistics.

B

number of bootstrap resamples to make.

rsize

Number giving the resample size for each bootstrap sample. Must be between 1 and the length of x, if x is a vector, else the number of rows of x. Default is to use the size of the original data.

block.length

Number giving the desired block lengths. Default (block.length = 1) is to do IID resamples. Should be longer than the length of dependence in the data, but much shorter than the size of the data.

replace

logical, should the resamples be taken with replacement?

v.terms

If statistic returns variance estimates for other parameters, then use this argument to specify the indices returned that give the variance estimates. There must be a component for every other parameter returned, and they must be in the same order as the other parameters (see examples below). If an estimate does not exist, an NA should be returned for that spot.

shuffle

rsize by B matrix giving the indices for each bootstrap replication. If provided, B may be missing.

Optional arguments passed to statistic.

Value

A list object of class “booted” is returned with components:

call

the function call

data

original data series

statistic

statistic argument passed in

statistic.args

all other arguments passed by …

B

Number of bootstrap replicate samples

block.length

The block length used

replace

logical stating whether the samples are taken with replacement or not.

v.terms

if variance terms are returned by statistic, the argument is repeated in the returned object.

rsize

the size of the bootstrap resamples.

indices

rsize by B matrix giving the resample indices used (rows) for each bootstrap resample (columns).

v

B length vector or B column matrix (if statistic returns a vector) giving the estimated parameter variances for each bootstrap replicate.

orig.v

vector giving the parameter variances (i.e. se^2) of statistic when applied to the original data.

original.est

vector giving the estimated parameter values when statistic is applied to the original data.

results

B length vector or B column matrix giving the parameter estimates for each bootstrap resample.

type

character stating whether the resample method is iid or cbb.

Details

Similar functionality to boot from package boot, but allows for easier implementation of certain other approaches. For example, m-out-of-n bootstrap resampling (appropriate for heavy-tail distributed data) can be performed via the rsize argument. The ci function is used to obtain subsequent confidence limits. For parameteric bootstrap resampling, see pbooter.

For more complicated bootstrap resampling, e.g., Bayesian bootstrap sampling, the shuffle argument may prove useful. That is, no weighting is allowed with this function through the standard mechanism, but the same result may be obtained by supplying your own indices through the shuffle argument. For parametric bootstrap resampling, see the pbooter function, but for certain types of parametric resampling, the shuffle argument could prove useful.

If the block length is > 1, then rsize overlapping blocks of this length are sampled from the data. In order to minimize over or under sampling of the end points, the blocks are circular (cf. Lahiri 2003).

Many good books and other materials are available about bootstrap resampling. One good text on IID bootstrap resampling is Efron and Tibshirani (1998) and for the block bootstrap, Lahiri (2003).

References

Efron, B. and Tibshirani, R. J. (1998) An Introduction to the Bootstrap. Chapman \& Hall, Boca Raton, Florida, 436 pp.

Lahiri, S. N. (2003) Resampling Methods for Dependent Data. Springer-Verlag, New York, New York, 374 pp.

See Also

pbooter, ci.booted tibber

Examples

Run this code
# NOT RUN {
z <- rnorm( 100 )

zfun <- function( data, ... ) {

    return( c( mean( data ), var( data ), mean( data^2 ), var( data^2 ) ) )

} # end of 'zfun' function.

res <- booter( x = z, statistic = zfun, B = 500, v.terms = c(2, 4) )

print( res )

# }
# NOT RUN {
 ci( res ) 
# }

Run the code above in your browser using DataLab