View source: R/confIntProportion.R
confIntProportion | R Documentation |
Compute a confidence interval for binomial proportions using several asymptotic and exact methods.
confIntProportion(x, n, conf.level = 0.95)
wald(x, n, conf.level = 0.95)
wilson(x, n, conf.level = 0.95)
agresti(x, n, conf.level = 0.95)
jeffreys(x, n, conf.level = 0.95)
clopperPearson(x, n, conf.level = 0.95)
x |
Number of successes. |
n |
Total number of trials. |
conf.level |
Confidence level for confidence interval. Default is 0.95. |
confIntProportion
returns a data.frame with confidence
intervals from the Wald, Wilson, Agresti, Jeffreys, and Clopper-Pearson
methods.
wald
returns the Wald confidence interval.
wilson
returns the Wilson confidence interval.
agresti
returns the Agresti confidence interval.
jeffreys
returns the Jeffreys confidence interval.
clopperPearson
returns the Clopper-Pearson confidence interval.
Kaspar Rufibach, Leonhard Held, Florian Gerber
All the intervals provided in these functions are compared in:
Brown, L.D., Cai, T.T., DasGupta, A. (2001). Interval Estimation for a Binomial Proportion. Statistical Science, 16(2), 101–133.
Functions for some of the intervals provided here are available in
Hmisc. confIntIndependentProportion
## Calculate confidence bounds for a binomial parameter using different methods.
x <- 50
n <- 100
ci <- confIntProportion(x = x, n = n)$CIs
ci
plot(0, 0, type = "n", ylim = c(0, 7), xlim = c(0, 1), xlab = "p",
ylab = "", yaxt = "n")
for(i in 1:5)
lines(ci[i, 2:3], c(i, i))
text(0.5, 0.85, "wald")
text(0.5, 1.85, "wilson")
text(0.5, 2.85, "agresti")
text(0.5, 3.85, "jeffreys")
text(0.5, 4.85, "clopper")
## compare intervals to those received by the function binconf in Hmisc:
if (require("Hmisc")) {
binconf(x, n, method = "asymptotic") # Wald
binconf(x, n, method = "wilson") # Wilson
binconf(x, n, method = "exact") # Clopper-Pearson
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.