View source: R/descriptive_stats.R
prec_prop | R Documentation |
prec_prop
returns the sample size or the precision for the provided
proportion.
prec_prop(
p,
n = NULL,
conf.width = NULL,
conf.level = 0.95,
method = c("wilson", "agresti-coull", "exact", "wald"),
...
)
p |
proportion. |
n |
number of observations. |
conf.width |
precision (the full width of the confidence interval). |
conf.level |
confidence level. |
method |
The method to use to calculate precision. Exactly one method may be provided. Methods can be abbreviated. |
... |
other arguments to uniroot (e.g. |
Exactly one of the parameters n
or conf.width
must be passed as NULL,
and that parameter is determined from the other.
The wilson, agresti-coull, exact, and wald method are implemented. The
wilson method is suggested for small n
(< 40), and the agresti-coull method
is suggested for larger n
(see reference). The wald method is not suggested,
but provided due to its widely distributed use.
uniroot
is used to solve n
for the agresti-coull,
wilson, and exact methods. Agresti-coull can be abbreviated by ac.
Object of class "presize", a list of arguments (including the
computed one) augmented with method and note elements. In the wilson and
agresti-coull formula, the p from which the confidence interval is
calculated is adjusted by a term (i.e. p + term \pm ci
). This
adjusted p is returned in padj
.
Brown LD, Cai TT, DasGupta A (2001) Interval Estimation for a Binomial Proportion, Statistical Science, 16:2, 101-117, \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1214/ss/1009213286")}
binom.test
, binom.confint
in package binom, and binconf
in package
Hmisc
# CI width for 15\% with 50 participants
prec_prop(0.15, n = 50)
# number of participants for 15\% with a CI width of 0.2
prec_prop(0.15, conf.width = 0.2)
# confidence interval width for a range of scenarios between 10 and 90\% with
# 100 participants via the wilson method
prec_prop(p = 1:9 / 10, n = 100, method = "wilson")
# number of participants for a range of scenarios between 10 and 90\% with
# a CI of 0.192 via the wilson method
prec_prop(p = 1:9 / 10, conf.width = .192, method = "wilson")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.