Uses optimization to minimize the integrated mean squared error between the calculated coverage and the desired confidence level for a given binomial confidence interval.
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, ...)
The number of independent trials in the binomial experiment.
The level of confidence to be used in the confidence interval.
The method used to estimate the confidence interval.
See Details.
The minimum probability of success to allow in the optimization. See Details.
logical; If TRUE
the optimizer will do an
unconstrained optimization on the signficance probability in the
logit space.
logical; If TRUE
the results are sent to binom.plot
.
The minimum significance level to allow in the optimization. See Details.
A starting value on the optimal confidence level.
Additional arguments to pass to optim
.
A list
with the following elements:
Final confidence levels. The length of this vector is
k
.
The final minimized value from optim
.
The number of function and gradient calls from
optim
.
Convergence code from optim
.
Any message returned by the L-BFGS-B or BFGS optimizer.
A data.frame
returned from a call to
method
using the optimized confidence levels.
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
.
# NOT RUN {
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 DataLab