binom.optim: Optimal binomial confidence intervals

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/binom.optim.R

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

1
2
3
4
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.

Details

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

alpha[opt]=argmin[alpha] integral[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.

Value

A list with the following elements:

par

Final confidence levels. The length of this vector is k.

value

The final minimized value from optim.

counts

The number of function and gradient calls from optim.

convergence

Convergence code from optim.

message

Any message returned by the L-BFGS-B or BFGS optimizer.

confint

A data.frame returned from a call to method using the optimized confidence levels.

Author(s)

Sundar Dorai-Raj (sdorairaj@gmail.com)

See Also

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

Examples

1
2
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

binom documentation built on May 2, 2019, 5:16 p.m.

Related to binom.optim in binom...