Skip to contents

The standard error of every statistic statistics() reports, from the per-simulation results alone. Each replicate draws the simulations with replacement, one draw shared by every column so their joint structure is kept, and reads the statistics from the resample counts on each column's order, sorted once; a statistic's standard error is the sample SD (dividing by B - 1) of its replicates values.

Usage

bootstrap_se(
  x,
  percentiles,
  replicates = 200,
  seed = 0,
  hold_fixed = NULL,
  tvar_levels = c(99, 99.5, 99.6, 99.8, 99.9, 99.99),
  sd_multiples = c(1, 2, 3),
  quantile = "inverted_cdf",
  tvar = "exact"
)

Arguments

x

A numeric vector of draws or a sampled, a named list or data frame of numeric vectors of equal length, or a predictive_distribution (one row per component). A list's vectors and a distribution's components share each replicate's draw.

percentiles

Percentiles, in percent, in [0, 100].

replicates

Number of replicates, at least 2.

seed

Replicate b draws from stream b of seed.

hold_fixed

NULL, or the fixed part of each column, of the same kind as x: a vector for a vector, a list with the same names for a list, a predictive_distribution with the same components for one.

tvar_levels, sd_multiples, quantile, tvar

As for statistics().

Value

For draws or a sampled, a named numeric vector of standard errors. For a list, a data frame with an item column and one column per statistic. For a predictive_distribution, its keys data frame with one column per statistic.

Details

With hold_fixed, each simulation keeps its fixed part (a tiled catalogue's loss, say) and only the rest is resampled: replicate simulation i is hold_fixed[i] + (x - hold_fixed)[s_i], so the errors are conditional on the fixed part.

Examples

x <- (seq_len(1000) * 37) %% 1000
se <- bootstrap_se(x, 50, replicates = 200, seed = 7)
se["Mean"]
#>     Mean 
#> 8.694003