Skip to content

BootSE

Description

BootSE is a thin wrapper around Bootstrap that returns the standard error of a bootstrapped statistic for a given sample. This is most convenient for statistics for which there is no strong theoretical basis to determine the standard error from a single sample.

Syntax

BootSE(sample, fn, [B=1000], [bw=0]) where

  • sample is the data sample, which can be univariate (row or column vector) or multivariate (matrix, with rows as observations). If multivariate, resampling is by rows.
  • fn is a LAMBDA function that is applied to each bootstrap sample. For example to bootstrap the mean one would use LAMBDA(x, AVERAGE(x)) for the callback function. The function must return a single, scalar value: the statistic that is bootstrapped.
  • B is the number of times the bootstrap re-samples the original sample (default is 1000)
  • bw is the bandwidth of the KDE for a smoothed bootstrap (default is bw = 0 meaning no smoothing at all). This argument is ignored if the sample is multivariate.

The function returns the standard error. This is a volatile function.

Example

The example below calculates the standard error of four locator statistics using bootstrap statistics. The original sample contains significant outliers which cause a negative skew. The non-bootstrap standard errors are also calculated (from the Central Limit Theorem) for the untrimmed and trimmed mean.

As can be seen, the bootstrap std errors are very similar to those calculated from the CLT. But there is no strong theoretical justification for similar formulas for the median and the kernel mode estimate (which is estimated using the KDEmax function). All three robust statistics have similar standard errors, though the median (which is estimated with a smoothed bootstrap) is slightly higher than the other two.

Note that TRIMMEAN(X, 40%) calculates the 20% trimmed mean of sample X.

KDE of the errors, and BootSE results matching the formula SEs: mean 0.17, 20% trimmed mean 0.031, median 0.034, KDEmax 0.031

The numbers in the Excel file below might be slightly different since BootSE is a volatile function.

Download: BootSE.xlsx

Source Code

Helpers used: BootObs

As you can see below, BootSE is a thin wrapper for Bootstrap, which returns the actual statistics.

BootSE = LAMBDA(
    sample,
    fn,     // statistic to apply to each bootstrap sample
    [B],    // number of bootstrap samples (default 1000)
    [bw],   // smoothing bandwidth factor, same meaning as KDE's bw (default 0 = unsmoothed)
    STDEV.S(Bootstrap(sample, fn, IF(ISOMITTED(B), 1000, B), IF(ISOMITTED(bw), 0, bw)))
);