prec_prop: Sample size or precision for a proportion

Description Usage Arguments Details Value References See Also Examples

View source: R/descriptive_stats.R

Description

prec_prop returns the sample size or the precision for the provided proportion

Usage

1
2
3
prec_prop(p, n = NULL, conf.width = NULL, conf.level = 0.95,
  method = c("wilson", "agresti-coull", "exact", "wald"),
  tol = .Machine$double.eps^0.25)

Arguments

p

proportion

n

number of observations

conf.width

precision (the full width of the conficende interval)

conf.level

confidence level

method

The method to use to calculate precision. Exactly one method may be provided. Methods can be abbreviated.

tol

numerical tolerance used in root finding, the default providing (at least) four significant digits

Details

Exactly one of the parameters n, 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 mehtod 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 method. Agresti-coull can be abbreviated by ac.

Value

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 wich the confidence interval is calculated is adjusted by a term (i.e. p + term \pm ci). This adjusted p is returned in padj.

References

Brown LD, Cai TT, DasGupta A (2001) Interval Estimation for a Binomial Proportion, Statistical Science, 16:2, 101-117, doi:10.1214/ss/1009213286

See Also

binom.test, binom.confint in package binom, and binconf in package Hmisc

Examples

1
prec_prop(p = 1:9 / 10, n = 1:2 * 100, method = "wilson")

a-lenz/presize documentation built on May 17, 2019, 7:44 a.m.