ci_mean: CI for the Population Mean

View source: R/ci_measures_of_location.R

ci_meanR Documentation

CI for the Population Mean

Description

This function calculates CIs for the population mean. By default, Student's t method is used. Alternatively, Wald and bootstrap CIs are available.

Usage

ci_mean(
  x,
  probs = c(0.025, 0.975),
  type = c("t", "Wald", "bootstrap"),
  boot_type = c("stud", "bca", "perc", "norm", "basic"),
  R = 9999L,
  seed = NULL,
  ...
)

Arguments

x

A numeric vector.

probs

Lower and upper probabilities, by default c(0.025, 0.975).

type

Type of CI. One of "t" (default), "Wald", or "bootstrap".

boot_type

Type of bootstrap CI. Only used for type = "bootstrap".

R

The number of bootstrap resamples. Only used for type = "bootstrap".

seed

An integer random seed. Only used for type = "bootstrap".

...

Further arguments passed to boot::boot().

Details

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).

Value

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.

References

  1. Smithson, M. (2003). Confidence intervals. Series: Quantitative Applications in the Social Sciences. New York, NY: Sage Publications.

  2. Efron, B. and Tibshirani R. J. (1994). An Introduction to the Bootstrap. Chapman & Hall/CRC.

Examples

x <- 1:100
ci_mean(x)
ci_mean(x, type = "bootstrap", R = 999, seed = 1)  # Use larger R

confintr documentation built on June 7, 2023, 6:24 p.m.