Generate B bootstrap replicates of size rsize and apply a statistic to them. Can do IID or Circular Block Bootstrap (CBB) methods.
booter(x, statistic, B, rsize, block.length = 1, v.terms, shuffle = NULL,
replace = TRUE, ...)
Original data series. May be a vector, matrix or data frame object.
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.
number of bootstrap resamples to make.
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.
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.
logical, should the resamples be taken with replacement?
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.
rsize
by B
matrix giving the indices for each bootstrap replication. If provided, B
may be missing.
Optional arguments passed to statistic
.
A list object of class “booted” is returned with components:
the function call
original data series
statistic argument passed in
all other arguments passed by …
Number of bootstrap replicate samples
The block length used
logical stating whether the samples are taken with replacement or not.
if variance terms are returned by statistic, the argument is repeated in the returned object.
the size of the bootstrap resamples.
rsize by B matrix giving the resample indices used (rows) for each bootstrap resample (columns).
B length vector or B column matrix (if statistic returns a vector) giving the estimated parameter variances for each bootstrap replicate.
vector giving the parameter variances (i.e. se^2) of statistic when applied to the original data.
vector giving the estimated parameter values when statistic is applied to the original data.
B length vector or B column matrix giving the parameter estimates for each bootstrap resample.
character stating whether the resample method is iid or cbb.
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).
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.
# 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