binom (version 1.0-0)

binom.optim: Optimal binomial confidence intervals

Description

Uses optimization to minimize the integrated mean squared error between the calculated coverage and the desired confidence level for a given binomial confidence interval.

Usage

binom.optim(n, conf.level = 0.95, method = binom.lrt,
            k = n%/%2 + 1, p0 = 0, transform = TRUE,
            plot = FALSE, tol = .Machine$double.eps^0.5,
            start = NULL, ...)

Arguments

n
The number of independent trials in the binomial experiment.
conf.level
The level of confidence to be used in the confidence interval.
method
The method used to estimate the confidence interval.
k
See Details.
p0
The minimum probability of success to allow in the optimization. See Details.
transform
logical; If TRUE the optimizer will do an unconstrained optimization on the signficance probability in the logit space.
plot
logical; If TRUE the results are sent to binom.plot.
tol
The minimum significance level to allow in the optimization. See Details.
start
A starting value on the optimal confidence level.
...
Additional arguments to pass to optim.

Value

  • A list with the following elements:

    • par
    {Final confidence levels. The length of this vector is k.}

  • valueThe final minimized value from optim.
  • countsThe number of function and gradient calls from optim.
  • convergenceConvergence code from optim.
  • messageAny message returned by the L-BFGS-B or BFGS optimizer.
  • confintA data.frame returned from a call to method using the optimized confidence levels.

Details

This function minimizes the squared error between the expected coverage probability and the desired confidence level.

$$\alpha_{opt}=\arg\min_{\alpha}\int_{0}^{1}[C(p,n)-(1-\alpha)^2dp$$

The optimizer will adjust confidence intervals for all x = 0 to n depending on the value of k provided. If k is one, only the confidence levels for x = 0 and n are adjusted. If k = [n/2] then all confidence intervals are adjusted. This assumes the confidence intervals are the same length for x = x[k] and x[n - k + 1], which is the case for all methods provided in this package except binom.cloglog.

See Also

binom.confint, binom.plot, binom.coverage, optim

Examples

Run this code
binom.optim(10, k = 1) ## determine optimal significance for x = 0, 10 only
binom.optim(3, method = binom.wilson) ## determine optimal significance for all x

Run the code above in your browser using DataCamp Workspace