# ci_proportion: Confidence Interval for a Population Proportion In confintr: Confidence Intervals

 ci_proportion R Documentation

## Confidence Interval for a Population Proportion

### Description

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

### Usage

```ci_proportion(
x,
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,
...
)
```

### Arguments

 `x` A numeric vector of 0 and 1 or the number of successes. `n` The sample size. Only needed if `x` is a vector of length 1. `probs` Error probabilites. The default c(0.025, 0.975) gives a symmetric 95% confidence interval. `type` Type of confidence interval. One of "Clopper-Pearson" (the default), "Agrestiâ€“Coull", "Wilson", "bootstrap". `boot_type` Type of bootstrap confidence interval ("bca", "perc", "stud", "norm", "basic"). 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

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 https://en.wikipedia.org/wiki/Binomial_proportion_confidence_interval which does not simplify the 0.975 quantile of the normal by 2 as sometimes in other references.

### Value

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.

### References

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.

### Examples

```x <- rep(0:1, times = c(50, 100))
ci_proportion(x)
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.