This function calculates CIs for the population mean. By default, Student's t method is used. Alternatively, Wald and bootstrap CIs are available.
A numeric vector.
Lower and upper probabilities, by default c(0.025, 0.975)
.
Type of CI. One of "t" (default), "Wald", or "bootstrap".
Type of bootstrap CI. Only used for type = "bootstrap"
.
The number of bootstrap resamples. Only used for type = "bootstrap"
.
An integer random seed. Only used for type = "bootstrap"
.
Further arguments passed to boot::boot()
.
An object of class "cint" containing these components:
parameter
: Parameter specification.
interval
: CI for the parameter.
estimate
: Parameter estimate.
probs
: Lower and upper probabilities.
type
: Type of interval.
info
: Additional description.
The default bootstrap type for the mean is "stud" (bootstrap t) as it enjoys the property of being second order accurate and has a stable variance estimator (see Efron, p. 188).
Smithson, M. (2003). Confidence intervals. Series: Quantitative Applications in the Social Sciences. New York, NY: Sage Publications.
Efron, B. and Tibshirani R. J. (1994). An Introduction to the Bootstrap. Chapman & Hall/CRC.
x <- 1:100
ci_mean(x)
#>
#> Two-sided 95% t confidence interval for the population mean
#>
#> Sample estimate: 50.5
#> Confidence interval:
#> 2.5% 97.5%
#> 44.74349 56.25651
#>
ci_mean(x, type = "bootstrap", R = 999, seed = 1) # Use larger R
#>
#> Two-sided 95% bootstrap confidence interval for the population mean
#> based on 999 bootstrap replications and the student method
#>
#> Sample estimate: 50.5
#> Confidence interval:
#> 2.5% 97.5%
#> 44.92988 56.27187
#>