bootstrap_experiment: Experimenting with sampling and calculating confidence...

Description Usage Arguments Details Value Functions Examples

Description

When bootstrapping, we are traditionally instructed to generate a sample equal in size to the entire dataset. We can shortcut this method, as long as we are willing to make certain adjustments when calculating confidence intervals. Two alternative sampling methods are tested here, one with replacement and the other without.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
bootstrap_experiment(funs, nrange = c(1000, 10000), rrange = c(0.25, 0.75),
  mus = c(0, 4.5), sigmas = c(1, 5.5), bsi_range = c(1000, 10000),
  length.out = 5, niter = 5)

compare_methods(param, funs)

bs_sim(x, bsi, replace, funs, n, b, ..., probs = c(0.025, 0.975))

red_se(x, probs = c(0.025, 0.975), n, b, xbar)

ss_quantiles(x, probs = c(0.025, 0.975), n, b, xbar)

quantile_ev(x, probs = c(0.025, 0.975), n, b, xbar, int = c(-500, 500))

se_ci(x, probs = c(0.025, 0.975), ...)

qntl(x, probs = c(0.025, 0.975), ...)

Arguments

funs

a list of functions for calculating confidence intervals

nrange

the length of the vector

rrange

the portion of the vector's length used in each subsample

mus

the mean of the sampling distribution

sigmas

the variance of the sampling distribution

bsi_range

the number of bootstrap iterations

length.out

the number of parameters drawn from the range

niter

the number of repetitions for each parameter combination

Details

The primary functions simulate data for estimating bootstrapped CIs for the mean of a normally-distributed vector. They accept ranges for the simulation parameters. These are described in the parameters. The experiment is generic in that you can pass it multiple different functions for calculating confidence intervals in a list. When these functions have different parameters, it is usually necessary to have ... in all of their arguments.

The simulation is split across one function to generate parameters and iterators, and a second function that executes a single iteration. That function also relies on a generic bootstrap simulator.

Value

The function experiment generates the test, which results in a data frame that contains:

Functions

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
## Not run: 
 red_se <- function(x, probs = c(.025, .975), n, b, mu) {
     se <- sd(x) * sqrt(b / n)
     qnorm(probs, mu, se)
 }

 funs <- list(se = red_se)
 test <- bootstrap_experiment(funs, length.out = 2, niter = 2)

## End(Not run)

michaelquinn32/adventureR documentation built on May 22, 2019, 9:52 p.m.