
Nonparametric Bootstrap Confidence Interval
Source:R/AllGenerics.R
, R/statistics.R
confidence_bootstrap.Rd
Computes equi-tailed two-sided nonparametric confidence interval.
Usage
confidence_bootstrap(object, ...)
# S4 method for class 'numeric'
confidence_bootstrap(
object,
level = 0.95,
type = c("basic", "normal", "student", "percentiles"),
t0 = NULL,
var_t0 = NULL,
var_t = NULL,
...
)
Arguments
- object
A
numeric
vector giving the bootstrap replicates of the statistic of interest.- ...
Currently not used.
- level
A length-one
numeric
vector giving the confidence level. Must be a single number between \(0\) and \(1\).- type
A
character
string giving the type of confidence interval to be returned. It must be one "basic
" (the default), "student
", "normal
" or "percentiles
". Any unambiguous substring can be given.- t0
A length-one
numeric
vector giving the observed value of the statistic of interest. Must be defined iftype
is "basic
", "student
" or "normal
".- var_t0
A length-one
numeric
vector giving an estimate of the variance of the statistic of interest. Must be defined iftype
is "student
". Ifvar_t0
is undefined andtype
is "normal
, it defaults tovar(object)
.- var_t
A
numeric
vector giving the variances of the bootstrap replicates of the variable of interest. Must be defined iftype
is "student
".
Value
A length-two numeric
vector giving the lower and upper confidence
limits.
References
Davison, A. C. & Hinkley, D. V. (1997). Bootstrap Methods and Their Application. Cambridge Series on Statistical and Probabilistic Mathematics. Cambridge: Cambridge University Press.
See also
Other summary statistics:
confidence_binomial()
,
confidence_mean()
,
confidence_multinomial()
,
interval_credible()
,
interval_hdr()
Examples
x <- rnorm(20)
## Bootstrap
bootstrap(x, do = mean, n = 100)
#> original mean bias error lower upper
#> 0.08847361 0.11258922 0.02411562 0.21393003 -0.34954034 0.42490420
## Estimate the 25th and 95th percentiles
quant <- function(x) { quantile(x, probs = c(0.25, 0.75)) }
bootstrap(x, n = 100, do = mean, f = quant)
#> 25% 75%
#> -0.03671968 0.19907598
## Get the n bootstrap estimates
(z <- bootstrap(x, n = 100, do = mean, f = function(x) { x }))
#> [1] 0.299590840 0.320153362 -0.259288473 0.164339635 -0.191425231
#> [6] -0.139810495 0.007416607 0.605360140 -0.166575424 -0.101487988
#> [11] 0.284748786 -0.007499523 0.004304247 0.218994186 0.021125206
#> [16] -0.056810271 0.059417104 0.161721338 0.015272930 0.375422699
#> [21] -0.181868435 -0.073487916 0.481650836 0.010074723 0.071206967
#> [26] 0.372160851 0.036152294 -0.067253393 0.093160454 0.034911981
#> [31] -0.137134500 -0.036490132 0.138077415 -0.006572719 -0.093006522
#> [36] -0.107602651 0.135752342 0.347914464 0.104548394 0.444301665
#> [41] -0.242253547 0.129326933 -0.366982591 -0.123817158 0.039819078
#> [46] -0.219225440 0.216401111 -0.185099896 0.286339982 0.364277313
#> [51] -0.151321700 -0.130989564 -0.320399508 0.164000414 0.304848028
#> [56] 0.066714927 0.287280325 0.404297289 -0.135315156 0.274131629
#> [61] -0.023868809 -0.043658558 -0.188440347 0.121464000 0.427792841
#> [66] -0.244275523 0.338741256 0.050022740 0.125660580 0.191986260
#> [71] -0.027042996 0.046467118 -0.025826127 0.208498186 0.057714806
#> [76] 0.024286810 -0.298886092 0.105710051 -0.087564438 0.422712513
#> [81] 0.028811940 0.385162438 0.009321958 0.073221907 -0.172764748
#> [86] 0.283707623 0.300469991 0.184487593 0.059698065 0.100689400
#> [91] 0.224082588 -0.077634668 0.490145448 0.045453867 0.113023531
#> [96] 0.078186624 0.235919571 0.625720208 0.046847795 0.232525693
## Basic bootstrap confidence interval
confidence_bootstrap(z, level = 0.95, type = "basic", t0 = mean(x))
#> lower upper
#> -0.3630975 0.4851507