binom.exact {exactci} | R Documentation |
Exact tests with matching confidence intervals for single binomial parameter
Description
Calculates exact p-values and confidence intervals for a single binomial parmeter.
This is different from binom.test
only when alternative='two.sided', in which
case binom.exact
gives three choices for tests based on the 'tsmethod' option.
The resulting p-values and confidence intervals will match.
Usage
binom.exact(x, n, p = 0.5,
alternative = c("two.sided", "less", "greater"),
tsmethod = c("central", "minlike", "blaker"),
conf.level = 0.95,
control=binomControl(),plot=FALSE, midp=FALSE)
Arguments
x |
number of successes, or a vector of length 2 giving the numbers of successes and failures, respectively. |
n |
number of trials, ignored if x has length 2. |
p |
hypothesized probability of success. |
alternative |
indicates the alternative hypothesis and must be one of "two.sided", "greater" or "less". You can specify just the initial letter. |
tsmethod |
indicates the method for a two-sided alternative hypothesis and must be one of "minlike", "central" or "blaker". You can specify just the initial letter. |
conf.level |
confidence level for the returned confidence interval. |
control |
list with settings to avoid problems with ties, etc, should not need to change this for normal use,
see |
plot |
logical, do basic plot of p-value function by null hypothesis value, see |
midp |
logical, use mid-p for p-values and confidence intervals? midp Confidence intervals are not available for tsmethod='minlike' and 'blaker' |
Details
Traditionally, hypothesis tests and confidence intervals are treated separately.
A more unified approach suggested by Hirji (2006) is to use the same p-value
function to create confidence intervals. There is essentially only one way to
calculate one-sided p-values and confidence intervals so these methods are the same
in binom.test
and binom.exact
. However,
there are three main ways that
binom.exact
allows for defining two-sided p-values.
minlike: | sum probabilities of all likelihoods equal or less than observed |
central: | double minimum one-sided p-value |
blaker: | combine smaller observed tail probability with opposite tail not greater than observed tail |
The 'minlike' method is the p-value that has been used in binom.test
,
and 'blaker' is described in Blaker (2000) or Hirji (2006), where it is called the
'combined tails' method.
Once the p-value function is defined we can invert the test to create 'matching'
confidence intervals defined as the smallest interval that contains all parameter values for which the two-sided
hypothesis test does not reject. There are some calculation issues for the
'minlike' and 'blaker' methods which are the same as for exact tests
for 2x2 tables (see Fay, 2010).
All of the above traditional p-values can be thought of as estimating Pr[X=xobs or X is more extreme than xobs] under the null hypothesis, where more extreme is defined differently for different methods. The mid-p-value replaces this with 0.5*Pr[X=xobs]+ Pr[X is more extreme than xobs]. The mid-p p-values are not valid. In other words, for all parameter values under the null hypothesis we are not guaranteed to bound the type I error rate. However, the usual exact methods that guarantee the type I error rate are typically conservative for most parameter values in order to bound the type I error rate for all parameter values. So if you are interested in rejecting approximately on average about 5 percent of the time for arbitrary parameter values and n values under the null hypothesis, then use midp=TRUE. If you want to ensure bounding of the type I errror rate for all n and all parameter values use midp=FALSE. (See for example, Vollset, 1993, or Hirji, 2006).
The associated midp confidence intervals have not been programmed for tsmethod='blaker' and 'minlike'.
Value
An object of class 'htest': a list with items
p.value |
p-value |
conf.int |
confidence interval, see attributes 'conf.level' and perhaps 'conf.limit.prec' |
statistic |
number of successes |
parameter |
number of trials |
estimate |
observed proportion of success |
null.value |
null hypothesis probability of success, 'p' |
alternative |
a character string describing alternative hypothesis |
method |
a character string describing method |
data.name |
a character string giving the names of the data |
Note
The 'central' method gives the Clopper-Pearson intervals, and the 'minlike' method gives confidence intervals proposed by Stern (1954) (see Blaker, 2000). The 'blaker' method is guaranteed to be more powerful than the 'central' method (see Blaker, 2000, Corollary 1), but both the 'blaker' method and 'minlike' method may have some undesireable properties. For example, there are cases where adding an additional Bernoulli observation REGARDLESS OF THE RESPONSE will increase the p-value, see Vos and Hudson (2008). The 'central' method does not have those undesireable properties.
The Blyth-Still-Casella intervals given in StatXact (and not by binom.exact
) are the shortest possible
intervals, but those intervals are not nested. This means that the Blyth-Still-Casella
intervals are not guaranteed
to have the 95 percent interval contain the 90 percent interval. See Blaker (2000) Theorem 2.
Author(s)
M.P. Fay
References
Blaker, H. (2000) Confidence curves and improved exact confidence intervals for discrete distributions. Canadian Journal of Statistics 28: 783-798.
Fay, M. P. (2010). Confidence intervals that Match Fisher's exact and Blaker's exact tests. Biostatistics. 11:373-374.
Fay, M.P. (2010). Two-sided Exact Tests and Matching Confidence Intervals for Discrete Data. R Journal 2(1): 53-58.
Hirji K. F. (2006). Exact analysis of discrete data. Chapman and Hall/CRC. New York.
Stern, T (1954). Some remarks on confidence and fiducial limits. Biometrika, 275-278.
Vollset, S. E. (1993). Confidence intervals for a binomial proportion. Statistics in medicine, 12(9), 809-824.
Vos, P.W. and Hudson, S. (2008). Problems with binomial two-sided tests and the associated confidence interals. Aust. N.Z. J. Stat. 50: 81-89.
See Also
binom.test
, for two-sample exact binomial tests see exact2x2
Examples
## Notice how binom.test p-value is given by tsmethod='minlike'
## but the confidence interval is given by tsmethod='central'
## in binom.exact p-values and confidence intervals match
binom.test(10,12,p=20000/37877)
binom.exact(10,12,p=20000/37877,tsmethod="minlike")
binom.exact(10,12,p=20000/37877,tsmethod="central")
binom.exact(10,12,p=20000/37877,tsmethod="blaker")
## one-sided methods are also available
## as in binom.test