bincon | R Documentation |
Calculates confidence intervals for binomial probabilities for specified
type-I error (alpha
) using exact, Wilson, asymptotic methods, or
two-stage methods.
For exact, Wilson, and asymptotic methods, r
and n
can be
any length (the other argument is recycled as needed).
For the two-stage method, r
and n
must each be length 2
where r = c(max # responses in 1st stage that can be observed
without continuing, total number of responses observed)
and
n = c(# of cases entered in 1st stage, # of additional cases
entered in 2nd stage)
.
bincon(
r,
n,
alpha = 0.05,
digits = getOption("digits"),
method = c("exact", "wilson", "asymptotic", "all", "two-stage"),
dp = 1,
max_width = TRUE
)
r |
number of responses (successes); if |
n |
number of observations (trials); if |
alpha |
type-I error probability |
digits |
integer value specifying number of decimal places |
method |
character strings specifying which method to use; can be (unambiguously) abbreviated; see details |
dp |
numeric value affecting the ordering of sample space in two-stage
designs when
|
max_width |
logical; if |
If method = 'all'
, r
and n
should each be length 1.
The "exact" method uses the df
distribution to comupte exact
intervals (based on the binomial cdf); the "wilson" interval is score-test-
based; the "asymptotic" is the asymptotic normal interval.
The "wilson" method has been preferred by Agresti and Coull.
method = "two-stage"
uses the twocon
function
from the desmon library:
First n[1]
patients are entered on the study. If more than
r[1]
responses are observed, then an additional n[2]
patients
are entered. This function assumes that if the observed number of responses
r < r[1]
, then only n[1]
patients were entered.
The estimators computed are the MLE (the observed proportion of responses), a bias corrected MLE, and an unbiased estimator, which is sometimes incorrectly described as the UMVUE.
The confidence interval is based on the exact sampling distribution.
However, there is not a universally accepted ordering on the sample space
in two-stage designs. The parameter dp
can be used to modify the
ordering by weighting points within the sample space differently.
dp=0
will give the Atkinson and Brown procedure, and dp=1
will order outcomes base on the MLE. The Atkinson and Brown procedure
orders outcomes based solely on the number of responses, regardless of the
number cases sampled.
The MLE ordering defines as more extreme those outcomes with a more extreme
value of the MLE (the proportion of responses). Other powers of dp
,
such as dp=1/2
, could also be used.
Let R
be the number of responses and N=n[1]
if
R <= r[1]
and N=n[1] + n[2]
if R>r[1]
. In general, the
outcomes that are more extreme in the high response direction are those
with R/(N^dp) >= r/(n^dp)
, where r
and n
are the
observed values of R
and N
, and the outcomes that are more
extreme in the low response direction are those with
R/(N^dp) <= r/(n^dp)
.
A matrix containing the computed interval(s) and their widths.
Rollin Brant, Frank Harrell, and Brad Biggerstaff; modifications by Robert Redd including support for two-stage designs
Agresti, A. and B.A. Coull. Approximate is better than "exact" for interval estimation of binomial proportions. American Statistician. 59:119-126, 1998.
Brown, L.D., T.T. Cai, and A. Das Gupta. Inverval estimation for a binomial proportion (with discussion). Statistical Science. 16:101-133, 2001.
Newcombe, R.G. Logit confidence intervals and the inverse sinh transformation, American Statistician. 55:200-2, 2001.
Atkinson E.N. and B.W. Brown. Biometrics. 41(3): 741-4, 1985.
binconr
; binconf
;
binci
; twocon
bincon(0, 10)
bincon(0:10, 10)
bincon(5, 10, method = 'all')
## two-stage confidence intervals
bincon(c(3, 4), c(14, 18), method = 'two-stage', dp = 0)
bincon(c(3, 4), c(14, 18), method = 'two-stage', dp = 1)
## ?desmon::twocon
## equivalent to
rawr:::twocon(14, 18, 3, 4, dp = 0)
rawr:::twocon(14, 18, 3, 4, dp = 1)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.