Learn R Programming

zipfR (version 0.6-10)

lnre.bootstrap: Parametric bootstrapping for LNRE models (zipfR)

Description

This function implements parametric bootstrapping for LNRE models, i.e. it draws a specified number of random samples from a trained lnre object. For each sample, a new model is estimated and user-defined information is extracted from this model. Please read the warning under "Details" below.

Usage

lnre.bootstrap(model, N, ESTIMATOR, STATISTIC, replicates=100,
                 simplify=TRUE, verbose=TRUE, seed=NULL, …)

Arguments

model

a trained LNRE model, i.e. an object belonging to a subclass of lnre. The model must provide a rlnre method to generate random samples from the underlying frequency distribution.

N

a single positive integer, specifying the size \(N\) (i.e. token count) of the individual bootstrap samples

ESTIMATOR

a callback function for estimating LNRE models in the bootstrap procedure. It is called for each bootstrap sample with the observed frequency spectrum as first argument and must return a trained LNRE model (i.e. an object belonging to a subcass of lnre). Additional arguments () are passed through to the estimator callback, so it is possible to use ESTIMATOR=lnre with appropriate settings.

STATISTIC

a callback function to extract relevant statistics from the bootstrapped LNRE models. It is called for each bootstrap sample with the estimated LNRE model as single argument. The return values are automatically aggregated across all bootstrap samples (see "Value" below).

replicates

a single positive integer, specifying the number of bootstrap samples to be generated

simplify

if TRUE, use rbind() to combine list of results into a single data structure. In this case, the estimator should return either a vector of fixed length or a single-row data frame.

verbose

if TRUE, shows progress bar in R console during execution (which can take quite a long time)

seed

a single integer value used to initialize the RNG in order to generate reproducible results

any further arguments are passed through to the ESTIMATOR callback function

Value

A list containing the statistics obtained from each individual bootstrap sample. If simplify=FALSE, the return value may be automatically simplified to a vector, matrix or data frame as appropriate.

Currently, automatic simplification is performed by sapply. In particular, if each call to STATISTIC returns a single number, the result is a vector; if it returns vectors of the same length, the result is a matrix. This behaviour is subject to change in future releases.

TODO: document attributes of return value; should they be included only if simplify=FALSE?

Details

Warning: The current implementation generates random samples of tokens and will be very inefficient for large values of N. It is not recommended to use this function for sample sizes of much more than 1 million tokens at this time.

See Also

lnre for more information about LNRE models. The high-level estimator function lnre uses lnre.bootstrap to collect data for approximate confidence intervals.

Examples

Run this code
# NOT RUN {
## TODO

# }

Run the code above in your browser using DataLab