Returns the necessary sample size to achieve a given width of a binomial confidence interval, as calculated by BinomCI()
. The function uses uniroot()
to find a numeric solution.
BinomCIn(p = 0.5, width, interval = c(1, 100000),
conf.level = 0.95, sides = "two.sided", method = "wilson")
probability for success, defaults to 0.5
.
the width of the confidence interval
a vector containing the end-points of the interval to be searched for the root. The defaults are set to c(1, 100000)
.
confidence level, defaults to 0.95
.
a character string specifying the side of the confidence interval, must be one of "two.sided"
(default),
"left"
or "right"
. You can specify just the initial letter. "left"
would be analogue to a hypothesis of
"greater"
in a t.test
.
character string specifing which method to use; this can be one out of:
"wald"
, "wilson"
, "wilsoncc"
, "agresti-coull"
, "jeffreys"
,
"modified wilson"
, "modified jeffreys"
, "clopper-pearson"
,
"arcsine"
, "logit"
, "witting"
or "pratt"
. Defaults to "wilson"
.
Abbreviation of method are accepted. See details in BinomCI()
.
a numeric value
The required sample sizes for a specific width of confidence interval depends on the proportion in the population. This value might be unknown right from the start when a study is planned. In such cases the sample size needed for a given level of accuracy can be estimated using the worst case percentage which is p=50%. When a better estimate is available you can you can use it to get a smaller interval.
BinomCI()
# NOT RUN {
BinomCIn(p=0.1, width=0.05, method="pratt")
# }
Run the code above in your browser using DataLab