Compute nonparametric bootstrap estimate, standard error, confidence intervals and p-value for a vector of bootstrap replicate estimates.

boot_ci(data, select = NULL, method = c("dist", "quantile"), ci.lvl = 0.95)

boot_se(data, select = NULL)

boot_p(data, select = NULL)

boot_est(data, select = NULL)

Arguments

data

A data frame that containts the vector with bootstrapped estimates, or directly the vector (see 'Examples').

select

Optional, unquoted names of variables (as character vector) with bootstrapped estimates. Required, if either data is a data frame (and no vector), and only selected variables from data should be processed.

method

Character vector, indicating if confidence intervals should be based on bootstrap standard error, multiplied by the value of the quantile function of the t-distribution (default), or on sample quantiles of the bootstrapped values. See 'Details' in boot_ci(). May be abbreviated.

ci.lvl

Numeric, the level of the confidence intervals.

Value

A data frame with either bootstrap estimate, standard error, the lower and upper confidence intervals or the p-value for all bootstrapped estimates.

Details

The methods require one or more vectors of bootstrap replicate estimates as input.

  • boot_est(): returns the bootstrapped estimate, simply by computing the mean value of all bootstrap estimates.

  • boot_se(): computes the nonparametric bootstrap standard error by calculating the standard deviation of the input vector.

  • The mean value of the input vector and its standard error is used by boot_ci() to calculate the lower and upper confidence interval, assuming a t-distribution of bootstrap estimate replicates (for method = "dist", the default, which is mean(x) +/- qt(.975, df = length(x) - 1) * sd(x)); for method = "quantile", 95\ confidence intervals (quantile(x, probs = c(0.025, 0.975))). Use ci.lvl to change the level for the confidence interval.

  • P-values from boot_p() are also based on t-statistics, assuming normal distribution.

References

Carpenter J, Bithell J. Bootstrap confdence intervals: when, which, what? A practical guide for medical statisticians. Statist. Med. 2000; 19:1141-1164

See also

[]bootstrap()] to generate nonparametric bootstrap samples.

Examples

data(efc)
bs <- bootstrap(efc, 100)

# now run models for each bootstrapped sample
bs$models <- lapply(
  bs$strap,
  function(.x) lm(neg_c_7 ~ e42dep + c161sex, data = .x)
)

# extract coefficient "dependency" and "gender" from each model
bs$dependency <- vapply(bs$models, function(x) coef(x)[2], numeric(1))
bs$gender <- vapply(bs$models, function(x) coef(x)[3], numeric(1))

# get bootstrapped confidence intervals
boot_ci(bs$dependency)
#>   term conf.low conf.high
#> 1 data 1.302479   1.75491

# compare with model fit
fit <- lm(neg_c_7 ~ e42dep + c161sex, data = efc)
confint(fit)[2, ]
#>    2.5 %   97.5 % 
#> 1.292945 1.796430 

# alternative function calls.
boot_ci(bs$dependency)
#>   term conf.low conf.high
#> 1 data 1.302479   1.75491
boot_ci(bs, "dependency")
#>         term conf.low conf.high
#> 1 dependency 1.302479   1.75491
boot_ci(bs, c("dependency", "gender"))
#>         term   conf.low conf.high
#> 1 dependency  1.3024793  1.754910
#> 2     gender -0.1838696  1.005308
boot_ci(bs, c("dependency", "gender"), method = "q")
#>         term   conf.low conf.high
#> 1 dependency  1.3263501 1.7280121
#> 2     gender -0.1274187 0.9603578


# compare coefficients
mean(bs$dependency)
#> [1] 1.528695
boot_est(bs$dependency)
#>   term estimate
#> 1 data 1.528695
coef(fit)[2]
#>   e42dep 
#> 1.544687