binCI {FSA} | R Documentation |
Uses one of three methods to compute a confidence interval for the probability of success (p) in a binomial distribution.
binCI( x, n, conf.level = 0.95, type = c("wilson", "exact", "asymptotic"), verbose = FALSE )
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 |
type |
A string that identifies the type of method to use for the calculations. See details. |
verbose |
A logical that indicates whether |
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
.
A #x2 matrix that contains the lower and upper confidence interval bounds as columns and, if verbose=TRUE
x
, n
, and x/n
.
This is primarily a wrapper function for binom.exact
, binom.wilson
, and binom.approx
(documented in binom.conf.int
) from the epitools package.
Derek H. Ogle, derek@derekogle.com
Agresti, A. and B.A. Coull. 1998. Approximate is better than “exact” for interval estimation of binomial proportions. American Statistician, 52:119-126.
See binom.test
; binconf
in Hmisc; binom.exact
, binom.wilson
, and binom.approx
documented in binom.conf.int
in epitools, and functions in binom.
## 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)