binomTestCoveragePlot {conf} | R Documentation |
Coverage Plots for Binomial Proportions
Description
Generates plots for the actual coverage of a binomial proportion
using various types of confidence intervals. Plots the actual
coverage for a given sample size and stated nominal coverage 1 -
alpha
.
Usage
binomTestCoveragePlot(n,
alpha = 0.05,
intervalType = "Clopper-Pearson",
plo = 0,
phi = 1,
clo = 1 - 2 * alpha,
chi = 1,
points = 5 + floor(250 / n),
showTrueCoverage = TRUE,
gridCurves = FALSE)
Arguments
n |
sample size |
alpha |
significance level for confidence interval |
intervalType |
type of confidence interval used; either "Clopper-Pearson", "Wald", "Wilson-Score", "Jeffreys", "Agresti-Coull", "Arcsine", or "Blaker" |
plo |
lower limit for percentile (horizontal axis) |
phi |
upper limit for percentile (horizontal axis) |
clo |
lower limit for coverage (vertical axis) |
chi |
upper limit for coverage (vertical axis) |
points |
number of points plotted in each segment of the plot; if default, varies with 'n' (see above) |
showTrueCoverage |
logical; if |
gridCurves |
logical; if |
Details
Generates an actual coverage plot for binomial proportions using
various types of confidence intervals, and
various sample sizes.
When the function is called with default arguments,
the horizontal axis is the percentile at which the coverage is evaluated,
the vertical axis is the actual coverage percentage at each percentile, that is, the probability that the true value at a percentile is contained in the corresponding confidence interval, and
the solid red line is the stated coverage of
1 -
alpha
.
The actual coverage for a particular value of p
, the percentile of interest, is
c(p) = \sum_{x=0}^n {I(x,p) {n \choose x} p^x (1-p)^{n-x}},
where I(x,p)
is an indicator function that determines whether a confidence interval covers p
when X = x
(see Vollset, 1993).
The binomial distribution with arguments size
= n
and
prob
= p
has probability mass function
p(x) = {n \choose x} p^x (1-p)^{n-x}
for x = 0, 1, \ldots, n
.
The algorithm for plotting the actual coverage begins by calculating all possible lower and upper bounds associated with the confidence interval procedure specified by the intervalType
argument.
These values are concatenated into a vector which is sorted. Negative values and values that exceed 1 are removed from this vector. These values are the breakpoints in the actual coverage function. The points
argument gives the number of points plotted on each segment of the graph of the actual coverage.
The plo
and phi
arguments can be used to expand or compress the plots horizontally.
The clo
and chi
arguments can be used to expand or compress the plots vertically.
By default, the showTrueCoverage
argument plots a solid horizontal
red line at the height of the stated coverage. The actual coverage is
plotted with solid black lines for each segment of the actual coverage.
The gridCurves
argument is assigned a logical value which indicates whether the acceptance curves giving all possible actual coverage values should be displayed as gray curves.
Author(s)
Hayeon Park (hpark031@gmail.com), Larry Leemis (leemis@math.wm.edu)
References
Vollset, S.E. (1993). Confidence Intervals for a Binomial Proportion. Statistics in Medicine, 12, 809–824.
See Also
Examples
binomTestCoveragePlot(6)
binomTestCoveragePlot(10, intervalType = "Wilson-Score", clo = 0.8)
binomTestCoveragePlot(n = 100, intervalType = "Wald", clo = 0, chi = 1, points = 30)