# negbintolint: Negative Binomial Tolerance Intervals In tolerance: Statistical Tolerance Intervals and Regions

## Description

Provides 1-sided or 2-sided tolerance intervals for negative binomial random variables. From a statistical quality control perspective, these limits use the number of failures that occur to reach `n` successes to bound the number of failures for a specified amount of future successes (`m`).

## Usage

 ```1 2 3``` ```negbintol.int(x, n, m = NULL, alpha = 0.05, P = 0.99, side = 1, method = c("LS", "WU", "CB", "CS", "SC", "LR", "SP", "CC")) ```

## Arguments

 `x` The total number of failures that occur from a sample of size `n`. Can be a vector of length `n`, in which case the sum of `x` is computed. `n` The target number of successes (sometimes called size) for each trial. `m` The target number of successes in a future lot for which the tolerance limits will be calculated. If `m = NULL`, then the tolerance limits will be constructed assuming `n` for the target number of future successes. `alpha` The level chosen such that `1-alpha` is the confidence level. `P` The proportion of the defective (or acceptable) units in future samples of size `m` to be covered by this tolerance interval. `side` Whether a 1-sided or 2-sided tolerance interval is required (determined by `side = 1` or `side = 2`, respectively). `method` The method for calculating the lower and upper confidence bounds, which are used in the calculation of the tolerance bounds. The default method is `"LS"`, which is the large-sample method based on the MLE. `"WU"` is a Wald-type interval based on the UMVUE of the negative binomial proportion. `"CB"` is the Casella-Berger exact method. `"CS"` is a method based on chi-square percentiles. `"SC"` is the score method. `"LR"` is a likelihood ratio-based method. `"SP"` is a method using a saddlepoint approximation for the confidence intervals. `"CC"` gives a continuity-corrected version of the large-sample method and is appropriate when `n` is large. More information on these methods can be found in the "References".

## Details

This function takes the approach for Poisson and binomial random variables developed in Hahn and Chandra (1981) and applies it to the negative binomial case.

## Value

`negbintol.int` returns a data frame with items:

 `alpha` The specified significance level. `P` The proportion of defective (or acceptable) units in future samples of size `m`. `pi.hat` The probability of success in each trial, calculated by `n/(n+x)`. `1-sided.lower` The 1-sided lower tolerance bound. This is given only if `side = 1`. `1-sided.upper` The 1-sided upper tolerance bound. This is given only if `side = 1`. `2-sided.lower` The 2-sided lower tolerance bound. This is given only if `side = 2`. `2-sided.upper` The 2-sided upper tolerance bound. This is given only if `side = 2`.

## Note

Recall that the geometric distribution is the negative binomial distribution where the size is 1. Therefore, the case when `n = m = 1` will provide tolerance limits for a geometric distribution.

## References

Casella, G. and Berger, R. L. (1990), Statistical Inference, Duxbury Press.

Hahn, G. J. and Chandra, R. (1981), Tolerance Intervals for Poisson and Binomial Variables, Journal of Quality Technology, 13, 100–110.

Tian, M., Tang, M. L., Ng, H. K. T., and Chan, P. S. (2009), A Comparative Study of Confidence Intervals for Negative Binomial Proportions, Journal of Statistical Computation and Simulation, 79, 241–249.

Young, D. S. (2014), A Procedure for Approximate Negative Binomial Tolerance Intervals, Journal of Statistical Computation and Simulation, 84, 438–450.

`NegBinomial`, `umatol.int`
 ``` 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20``` ``` ## Comparison of 95%/99% 1-sided tolerance limits with ## 50 failures before 10 successes are reached. negbintol.int(x = 50, n = 10, side = 1, method = "LS") negbintol.int(x = 50, n = 10, side = 1, method = "WU") negbintol.int(x = 50, n = 10, side = 1, method = "CB") negbintol.int(x = 50, n = 10, side = 1, method = "CS") negbintol.int(x = 50, n = 10, side = 1, method = "SC") negbintol.int(x = 50, n = 10, side = 1, method = "LR") negbintol.int(x = 50, n = 10, side = 1, method = "SP") negbintol.int(x = 50, n = 10, side = 1, method = "CC") ## 95%/99% 1-sided tolerance limits and 2-sided tolerance ## interval for the same setting above, but when we are ## interested in a future experiment that requires 20 successes ## be reached for each trial. negbintol.int(x = 50, n = 10, m = 20, side = 1) negbintol.int(x = 50, n = 10, m = 20, side = 2) ```