Learn R Programming

FSA (version 0.8.20)

binCI: Confidence intervals for binomial probability of success.

Description

Uses one of three methods to compute a confidence interval for the probability of success (p) in a binomial distribution.

Usage

binCI(x, n, conf.level = 0.95, type = c("wilson", "exact", "asymptotic"),
  verbose = FALSE)

Arguments

x

A single or vector of numbers that contains the number of observed successes.

n

A single or vector of numbers that contains the sample size.

conf.level

A single number that indicates the level of confidence (default is 0.95).

type

A string that identifies the type of method to use for the calculations. See details.

verbose

A logical that indicates whether x, n, and x/n should be included in the returned matrix (=TRUE) or not (=FALSE; DEFAULT).

Value

A #x2 matrix that contains the lower and upper confidence interval bounds as columns and, if verbose=TRUE x, n, and x/n .

Details

This function will compute confidence interval for three possible methods chosen with the type argument.

type="wilson" Wilson's (Journal of the American Statistical Association, 1927) confidence interval for a proportion. This is the score CI, based on inverting the asymptotic normal test using the null standard error.
type="exact" Computes the Clopper/Pearson exact CI for a binomial success probability.
type="asymptotic" This uses the normal distribution approximation.

Note that Agresti and Coull (2000) suggest that the Wilson interval is the preferred method and is, thus, the default type.

References

Agresti, A. and B.A. Coull. 1998. Approximate is better than “exact” for interval estimation of binomial proportions. American Statistician, 52:119-126.

See Also

See binom.test; binconf in Hmisc; binom.exact, binom.wilson, and binom.approx documented in binom.conf.int in epitools, and functions in binom.

Examples

Run this code
# NOT RUN {
## All types at once
binCI(7,20)

## Individual types
binCI(7,20,type="wilson")
binCI(7,20,type="exact")
binCI(7,20,type="asymptotic")
binCI(7,20,type="asymptotic",verbose=TRUE)

## Multiple types
binCI(7,20,type=c("exact","asymptotic"))
binCI(7,20,type=c("exact","asymptotic"),verbose=TRUE)

## Use with multiple inputs
binCI(c(7,10),c(20,30),type="wilson")
binCI(c(7,10),c(20,30),type="wilson",verbose=TRUE)

# }

Run the code above in your browser using DataLab