
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.08279935 0.09685068 0.01405133 0.20377014 -0.26938036 0.47008738
## 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.09889091 0.22972109
## Get the n bootstrap estimates
(z <- bootstrap(x, n = 100, do = mean, f = function(x) { x }))
#> [1] -0.035656778 -0.053098012 0.014194773 -0.304153085 0.429528200
#> [6] 0.309721402 -0.301880008 -0.494729833 0.170585485 0.368156817
#> [11] -0.008692328 -0.309785421 -0.430884902 0.038125908 0.150895816
#> [16] 0.063440799 0.403047158 -0.254249105 0.277451781 -0.180174048
#> [21] 0.136977561 0.133339186 -0.219018859 0.001371939 0.151657349
#> [26] 0.076535065 -0.015714782 0.054881079 0.270960997 0.420687834
#> [31] -0.026064502 0.451707491 0.149567475 -0.038791862 0.042045703
#> [36] -0.253326216 0.294054191 -0.278628210 0.247845605 0.408845224
#> [41] 0.252016122 -0.172545540 0.147479587 0.070363716 0.204599572
#> [46] 0.069778831 0.340138888 0.363690882 0.446092193 0.190168714
#> [51] 0.080816400 -0.140582569 0.104200511 -0.057835514 0.192533291
#> [56] 0.452635100 -0.127770213 0.119903582 -0.042454819 0.320664719
#> [61] 0.221692723 0.012401290 0.300825087 -0.076051473 -0.029352389
#> [66] 0.042625162 0.342830883 0.437672541 0.182484926 -0.045915373
#> [71] 0.289773492 -0.122575438 0.014241826 -0.171322535 0.359392484
#> [76] 0.220794210 -0.070381035 0.248234484 0.024892025 -0.045864214
#> [81] 0.113510789 0.365889324 0.083406503 0.020579296 -0.026991366
#> [86] 0.268508480 0.366075776 0.048669628 0.414410266 -0.287654397
#> [91] -0.026251097 0.114271864 0.486579786 0.079339214 0.174145719
#> [96] 0.049649180 -0.194323305 0.206408981 -0.060836371 0.104003501
## Basic bootstrap confidence interval
confidence_bootstrap(z, level = 0.95, type = "basic", t0 = mean(x))
#> lower upper
#> -0.2865105 0.5278321