ci_proportion: Confidence Interval for a Population Proportion

View source: R/ci_proportion.R

ci_proportionR Documentation

Confidence Interval for a Population Proportion


This function calculates confidence intervals for a population proportion. By default, "Clopper-Pearson" confidence intervals are calculated (via stats::binom.test). Further possibilities are "Wilson", "Agresti-Coull", and "bootstrap" (mainly added for consistency and didactic purposes).


  n = NULL,
  probs = c(0.025, 0.975),
  type = c("Clopper-Pearson", "Agresti-Coull", "Wilson", "bootstrap"),
  boot_type = c("bca", "perc", "stud", "norm", "basic"),
  R = 9999,
  seed = NULL,



A numeric vector of 0 and 1 or the number of successes.


The sample size. Only needed if x is a vector of length 1.


Error probabilites. The default c(0.025, 0.975) gives a symmetric 95% confidence interval.


Type of confidence interval. One of "Clopper-Pearson" (the default), "Agresti–Coull", "Wilson", "bootstrap".


Type of bootstrap confidence interval ("bca", "perc", "stud", "norm", "basic"). 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.


Bootstrap confidence intervals are calculated by the package "boot", see references. The default bootstrap type for the proportion is "bca" (bias-corrected accelerated) as it enjoys the property of being second order accurate as well as transformation respecting (see Efron, p. 188). Note that we use the formula in which does not simplify the 0.975 quantile of the normal by 2 as sometimes in other references.


A list with class cint containing these components:

  • parameter: The parameter in question.

  • interval: The confidence interval for the parameter.

  • estimate: The estimate for the parameter.

  • probs: A vector of error probabilities.

  • type: The type of the interval.

  • info: An additional description text for the interval.


  1. Clopper, C. and Pearson, E. S. (1934). The use of confidence or fiducial limits illustrated in the case of the binomial. Biometrika. 26 (4).

  2. Wilson, E. B. (1927). Probable inference, the law of succession, and statistical inference. Journal of the American Statistical Association, 22 (158).

  3. Agresti, A. and Coull, B. A. (1998). Approximate is better than 'exact' for interval estimation of binomial proportions. The American Statistician, 52 (2).

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

  5. Canty, A and Ripley B. (2019). boot: Bootstrap R (S-Plus) Functions.


x <- rep(0:1, times = c(50, 100))
ci_proportion(x, type = "Wilson")
ci_proportion(x, type = "Agresti-Coull")
ci_proportion(x, type = "bootstrap", R = 999)

confintr documentation built on Sept. 29, 2022, 5:13 p.m.