bincon: Binomial probability confidence intervals

View source: R/stat.R

binconR Documentation

Binomial probability confidence intervals

Description

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).

Usage

bincon(
  r,
  n,
  alpha = 0.05,
  digits = getOption("digits"),
  method = c("exact", "wilson", "asymptotic", "all", "two-stage"),
  dp = 1,
  max_width = TRUE
)

Arguments

r

number of responses (successes); if method = 'two-stage', a vector of length two giving the max number of responses that can be observed in the first stage without continuing and the total number of responses observed

n

number of observations (trials); if method = 'two-stage', a vector of length two giving the number of cases entered during the first stage and the number of additional cases to be entered during the second stage

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 method = "two-stage"

dp = 0 will give the Atkinson and Brown procedure, and dp = 1 (default) will order based on MLE; values such as dp = 0.5 can also be used; see details

max_width

logical; if TRUE, the maximum width of each confidence interval is given for n

Details

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).

Value

A matrix containing the computed interval(s) and their widths.

Author(s)

Rollin Brant, Frank Harrell, and Brad Biggerstaff; modifications by Robert Redd including support for two-stage designs

References

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.

See Also

binconr; binconf; binci; twocon

Examples

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)


raredd/rawr documentation built on March 4, 2024, 1:36 a.m.